Top Description Inners Fields Constructors Methods
com.mysql.cj.protocol

public Class ExportControlled

extends Object
Class Inheritance
Imports
java.io.IOException, .InputStream, java.net.MalformedURLException, .Socket, .URL, java.security.InvalidAlgorithmParameterException, .InvalidKeyException, .KeyFactory, .KeyManagementException, .KeyStore, .KeyStoreException, .NoSuchAlgorithmException, .NoSuchProviderException, .Signature, .SignatureException, .UnrecoverableKeyException, java.security.cert.CertPath, .CertPathValidator, .CertPathValidatorException, .CertPathValidatorResult, .Certificate, .CertificateException, .CertificateFactory, .PKIXCertPathValidatorResult, .PKIXParameters, .TrustAnchor, .X509CertSelector, .X509Certificate, java.security.interfaces.RSAPrivateKey, .RSAPublicKey, java.security.spec.InvalidKeySpecException, .PKCS8EncodedKeySpec, .X509EncodedKeySpec, java.util.ArrayList, .Arrays, .Base64, .Collection, .List, .Properties, .Set, java.util.stream.Collectors, .Stream, javax.crypto.BadPaddingException, .Cipher, .IllegalBlockSizeException, .NoSuchPaddingException, javax.naming.InvalidNameException, javax.naming.ldap.LdapName, javax.net.ssl.KeyManager, .KeyManagerFactory, .SSLContext, .SSLSession, .SSLSocket, .SSLSocketFactory, .TrustManager, .TrustManagerFactory, .X509TrustManager, javax.security.auth.x500.X500Principal, com.mysql.cj.ServerVersion, com.mysql.cj.conf.PropertyDefinitions.SslMode, .PropertyKey, .PropertySet, .RuntimeProperty, com.mysql.cj.exceptions.CJCommunicationsException, .ExceptionFactory, .ExceptionInterceptor, .FeatureNotAvailableException, .RSAException, .SSLParamsException, com.mysql.cj.log.Log, com.mysql.cj.util.Base64Decoder, .StringUtils

Holds functionality that falls under export-control regulations.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
private static class
public static class
ExportControlled.X509TrustManagerWrapper

X509TrustManager wrapper that allows skipping server certificate validation and adds certificate expiration check.

Field Summary

Modifier and TypeField and Description
private static final List<String>
private static final String[]
private static final String[]
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final List<String>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static void
public static RSAPrivateKey
public static RSAPublicKey
public static boolean
public static byte[]
encryptWithRSAPublicKey(byte[] source, RSAPublicKey key, String transformation)

public static byte[]
private static String[]
getAllowedCiphers(PropertySet pset, List<String> socketCipherSuites)

private static String[]
getAllowedProtocols(PropertySet pset, String[] socketProtocols)

private static ExportControlled.KeyStoreConfigurations
private static ExportControlled.KeyStoreConfigurations
private static List<String>
public static boolean
public static Socket

Returns:

SSL socket
performTlsHandshake
(Socket
original non-SSL socket
rawSocket
,
SocketConnection
the Protocol instance containing the socket to convert into an SSLSocket.
socketConnection
,
ServerVersion
ServerVersion object
serverVersion
,
Log
Logger
log
)

Converts the socket being used in the given SocketConnection to an SSLSocket by performing the TLS handshake.

public static byte[]
sign(byte[] source, RSAPrivateKey privateKey)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ALLOWED_CIPHERSback to summary
private static final List<String> ALLOWED_CIPHERS
APPROVED_TLS_PROTOCOLSback to summary
private static final String[] APPROVED_TLS_PROTOCOLS
KNOWN_TLS_PROTOCOLSback to summary
private static final String[] KNOWN_TLS_PROTOCOLS
SSL_CONTEXT_PROTOCOLback to summary
private static final String SSL_CONTEXT_PROTOCOL
TLS_SETTINGS_RESOURCEback to summary
private static final String TLS_SETTINGS_RESOURCE
TLSv1back to summary
private static final String TLSv1
TLSv1_1back to summary
private static final String TLSv1_1
TLSv1_2back to summary
private static final String TLSv1_2
TLSv1_3back to summary
private static final String TLSv1_3
UNACCEPTABLE_CIPHER_SUBSTRback to summary
private static final List<String> UNACCEPTABLE_CIPHER_SUBSTR

Constructor Detail

ExportControlledback to summary
private ExportControlled()

Method Detail

checkValidProtocolsback to summary
public static void checkValidProtocols(List<String> protocols)
decodeRSAPrivateKeyback to summary
public static RSAPrivateKey decodeRSAPrivateKey(String key) throws RSAException
decodeRSAPublicKeyback to summary
public static RSAPublicKey decodeRSAPublicKey(String key) throws RSAException
enabledback to summary
public static boolean enabled()
encryptWithRSAPublicKeyback to summary
public static byte[] encryptWithRSAPublicKey(byte[] source, RSAPublicKey key, String transformation) throws RSAException
encryptWithRSAPublicKeyback to summary
public static byte[] encryptWithRSAPublicKey(byte[] source, RSAPublicKey key) throws RSAException
getAllowedCiphersback to summary
private static String[] getAllowedCiphers(PropertySet pset, List<String> socketCipherSuites)
getAllowedProtocolsback to summary
private static String[] getAllowedProtocols(PropertySet pset, String[] socketProtocols)
getKeyStoreConfigurationsback to summary
private static ExportControlled.KeyStoreConfigurations getKeyStoreConfigurations(PropertySet propertySet)
getTrustStoreConfigurationsback to summary
private static ExportControlled.KeyStoreConfigurations getTrustStoreConfigurations(PropertySet propertySet)
getValidProtocolsback to summary
private static List<String> getValidProtocols(String[] protocols)
isSSLEstablishedback to summary
public static boolean isSSLEstablished(Socket socket)
performTlsHandshakeback to summary
public static Socket performTlsHandshake(Socket rawSocket, SocketConnection socketConnection, ServerVersion serverVersion, Log log) throws IOException, SSLParamsException, FeatureNotAvailableException

Converts the socket being used in the given SocketConnection to an SSLSocket by performing the TLS handshake.

Parameters
rawSocket:Socket

original non-SSL socket

socketConnection:SocketConnection

the Protocol instance containing the socket to convert into an SSLSocket.

serverVersion:ServerVersion

ServerVersion object

log:Log

Logger

Returns:Socket

SSL socket

Exceptions
IOException:
if an I/O exception occurs
SSLParamsException:
if the handshake fails
FeatureNotAvailableException:
if TLS is not supported
signback to summary
public static byte[] sign(byte[] source, RSAPrivateKey privateKey) throws RSAException
com.mysql.cj.protocol back to summary

private Class ExportControlled.HostnameChecker

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
match(X509Certificate certificate)

private boolean

Returns:

true if the host name matches the pattern, false otherwise.
verifyHostName
(String
the pattern to match with the host name.
ptn
)

Verify the host name against the given pattern, using the rules specified in RFC 6125, Section 6.4.3.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

hostnameback to summary
private String hostname

Constructor Detail

HostnameCheckerback to summary
public HostnameChecker(String hostname)

Method Detail

matchback to summary
public void match(X509Certificate certificate) throws CertificateException
verifyHostNameback to summary
private boolean verifyHostName(String ptn)

Verify the host name against the given pattern, using the rules specified in RFC 6125, Section 6.4.3. Support wildcard character as defined in the RFC.

Parameters
ptn:String

the pattern to match with the host name.

Returns:boolean

true if the host name matches the pattern, false otherwise.

com.mysql.cj.protocol back to summary

private Class ExportControlled.KeyStoreConfigurations

extends Object
Class Inheritance
  • java.lang.Object
  • com.mysql.cj.protocol.ExportControlled.KeyStoreConfigurations

Field Summary

Modifier and TypeField and Description
public String
public String
public String

Constructor Summary

AccessConstructor and Description
public
public
KeyStoreConfigurations(String keyStoreUrl, String keyStorePassword, String keyStoreType)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

keyStorePasswordback to summary
public String keyStorePassword
keyStoreTypeback to summary
public String keyStoreType
keyStoreUrlback to summary
public String keyStoreUrl

Constructor Detail

KeyStoreConfigurationsback to summary
public KeyStoreConfigurations()
KeyStoreConfigurationsback to summary
public KeyStoreConfigurations(String keyStoreUrl, String keyStorePassword, String keyStoreType)
com.mysql.cj.protocol back to summary

private Class ExportControlled.SslContextBuilder

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private ExceptionInterceptor
private boolean
private boolean
private String
private String
private ExportControlled.KeyStoreConfigurations
private String
private String
private ExportControlled.KeyStoreConfigurations
private boolean

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public SSLContext
public void
public void
setFallbackToSystemTrustStore(boolean fallbackToDefaultTrustStore)

public void
setFipsCompliantJsse(boolean fipsCompliantJsse)

public void
setKeyManagerFactoryProvider(String keyManagerFactoryProvider)

public void
setKeyStoreProvider(String keyStoreProvider)

public void
public void
setSslContextProvider(String sslContextProvider)

public void
setTrustManagerFactoryProvider(String trustManagerFactoryProvider)

public void
public void
setVerifyServerCertificate(boolean verifyServerCertificate)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

exceptionInterceptorback to summary
private ExceptionInterceptor exceptionInterceptor
fallbackToSystemTrustStoreback to summary
private boolean fallbackToSystemTrustStore
fipsCompliantJsseback to summary
private boolean fipsCompliantJsse
KeyManagerFactoryProviderback to summary
private String KeyManagerFactoryProvider
keyStoreProviderback to summary
private String keyStoreProvider
keyStoreSettingsback to summary
private ExportControlled.KeyStoreConfigurations keyStoreSettings
sslContextProviderback to summary
private String sslContextProvider
trustManagerFactoryProviderback to summary
private String trustManagerFactoryProvider
trustStoreSettingsback to summary
private ExportControlled.KeyStoreConfigurations trustStoreSettings
verifyServerCertificateback to summary
private boolean verifyServerCertificate

Constructor Detail

SslContextBuilderback to summary
public SslContextBuilder()

Method Detail

buildback to summary
public SSLContext build()
setExceptionInterceptorback to summary
public void setExceptionInterceptor(ExceptionInterceptor exceptionInterceptor)
setFallbackToSystemTrustStoreback to summary
public void setFallbackToSystemTrustStore(boolean fallbackToDefaultTrustStore)
setFipsCompliantJsseback to summary
public void setFipsCompliantJsse(boolean fipsCompliantJsse)
setKeyManagerFactoryProviderback to summary
public void setKeyManagerFactoryProvider(String keyManagerFactoryProvider)
setKeyStoreProviderback to summary
public void setKeyStoreProvider(String keyStoreProvider)
setKeyStoreSettingsback to summary
public void setKeyStoreSettings(ExportControlled.KeyStoreConfigurations keyStoreSettings)
setSslContextProviderback to summary
public void setSslContextProvider(String sslContextProvider)
setTrustManagerFactoryProviderback to summary
public void setTrustManagerFactoryProvider(String trustManagerFactoryProvider)
setTrustStoreSettingsback to summary
public void setTrustStoreSettings(ExportControlled.KeyStoreConfigurations keyStoreSettings)
setVerifyServerCertificateback to summary
public void setVerifyServerCertificate(boolean verifyServerCertificate)
com.mysql.cj.protocol back to summary

public Class ExportControlled.X509TrustManagerWrapper

extends Object
implements X509TrustManager
Class Inheritance
  • java.lang.Object
  • com.mysql.cj.protocol.ExportControlled.X509TrustManagerWrapper
All Implemented Interfaces
javax.net.ssl.X509TrustManager, javax.net.ssl.TrustManager

X509TrustManager wrapper that allows skipping server certificate validation and adds certificate expiration check.

Field Summary

Modifier and TypeField and Description
private static final String
private static final String
private CertificateFactory
private CertPathValidator
private X509TrustManager
private PKIXParameters
private boolean

Constructor Summary

AccessConstructor and Description
pack-priv
X509TrustManagerWrapper(X509TrustManager
if null then enables just certificate expiration check.
tm
)

Constructor for enabling server certificate validation and certificate expiration check.

pack-priv
X509TrustManagerWrapper()

Constructor for enabling just certificate expiration check.

Method Summary

Modifier and TypeMethod and Description
public void
checkClientTrusted(X509Certificate[]
the peer certificate chain
chain
,
String
the authentication type based on the client certificate
authType
)

Implements javax.net.ssl.X509TrustManager.checkClientTrusted.

Given the partial or complete certificate chain provided by the peer, build a certificate path to a trusted root and return if it can be validated and is trusted for client SSL authentication based on the authentication type.

public void
checkServerTrusted(X509Certificate[]
the peer certificate chain
chain
,
String
the key exchange algorithm used
authType
)

Implements javax.net.ssl.X509TrustManager.checkServerTrusted.

Given the partial or complete certificate chain provided by the peer, build a certificate path to a trusted root and return if it can be validated and is trusted for server SSL authentication based on the authentication type.

public X509Certificate[]
getAcceptedIssuers()

Implements javax.net.ssl.X509TrustManager.getAcceptedIssuers.

Return an array of certificate authority certificates which are trusted for authenticating peers.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CERT_FACTORY_TYPEback to summary
private static final String CERT_FACTORY_TYPE
CERT_PATH_VALIDATOR_ALGORITHMback to summary
private static final String CERT_PATH_VALIDATOR_ALGORITHM
certFactoryback to summary
private CertificateFactory certFactory
certPathValidatorback to summary
private CertPathValidator certPathValidator
originalTrustManagerback to summary
private X509TrustManager originalTrustManager
pkixParamsback to summary
private PKIXParameters pkixParams
validateServerCertback to summary
private boolean validateServerCert

Constructor Detail

X509TrustManagerWrapperback to summary
pack-priv X509TrustManagerWrapper(X509TrustManager tm) throws CertificateException

Constructor for enabling server certificate validation and certificate expiration check.

Parameters
tm:X509TrustManager

if null then enables just certificate expiration check.

X509TrustManagerWrapperback to summary
pack-priv X509TrustManagerWrapper() throws CertificateException

Constructor for enabling just certificate expiration check.

Method Detail

checkClientTrustedback to summary
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException

Implements javax.net.ssl.X509TrustManager.checkClientTrusted.

Doc from javax.net.ssl.X509TrustManager.checkClientTrusted.

Given the partial or complete certificate chain provided by the peer, build a certificate path to a trusted root and return if it can be validated and is trusted for client SSL authentication based on the authentication type.

The authentication type is determined by the actual certificate used. For instance, if RSAPublicKey is used, the authType should be "RSA". Checking is case-sensitive.

Parameters
chain:X509Certificate[]

the peer certificate chain

authType:String

the authentication type based on the client certificate

Annotations
@Override
Exceptions
CertificateException:
if the certificate chain is not trusted by this TrustManager.
checkServerTrustedback to summary
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException

Implements javax.net.ssl.X509TrustManager.checkServerTrusted.

Doc from javax.net.ssl.X509TrustManager.checkServerTrusted.

Given the partial or complete certificate chain provided by the peer, build a certificate path to a trusted root and return if it can be validated and is trusted for server SSL authentication based on the authentication type.

The authentication type is the key exchange algorithm portion of the cipher suites represented as a String, such as "RSA", "DHE_DSS".

Note

for some exportable cipher suites, the key exchange algorithm is determined at run time during the handshake. For instance, for TLS_RSA_EXPORT_WITH_RC4_40_MD5, the authType should be RSA_EXPORT when an ephemeral RSA key is used for the key exchange, and RSA when the key from the server certificate is used. Checking is case-sensitive.

Parameters
chain:X509Certificate[]

the peer certificate chain

authType:String

the key exchange algorithm used

Annotations
@Override
Exceptions
CertificateException:
if the certificate chain is not trusted by this TrustManager.
getAcceptedIssuersback to summary
public X509Certificate[] getAcceptedIssuers()

Implements javax.net.ssl.X509TrustManager.getAcceptedIssuers.

Doc from javax.net.ssl.X509TrustManager.getAcceptedIssuers.

Return an array of certificate authority certificates which are trusted for authenticating peers.

Returns:X509Certificate[]

a non-null (possibly empty) array of acceptable CA issuer certificates.

Annotations
@Override