Package org.conscrypt
Class SSLParametersImpl
- java.lang.Object
-
- org.conscrypt.SSLParametersImpl
-
- All Implemented Interfaces:
Cloneable
public class SSLParametersImpl extends Object implements Cloneable
The instances of this class encapsulate all the info about enabled cipher suites and protocols, as well as the information about client/server mode of ssl socket, whether it require/want client authentication or not, and controls whether new SSL sessions may be established by this socket or not.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceSSLParametersImpl.AliasChooserFor abstracting the X509KeyManager calls betweenX509KeyManager.chooseClientAlias(String[], java.security.Principal[], java.net.Socket)andX509ExtendedKeyManager.chooseEngineClientAlias(String[], java.security.Principal[], javax.net.ssl.SSLEngine)static interfaceSSLParametersImpl.PSKCallbacksFor abstracting thePSKKeyManagercalls between those taking anSSLSocketand those taking anSSLEngine.
-
Constructor Summary
Constructors Modifier Constructor Description protectedSSLParametersImpl(KeyManager[] kms, TrustManager[] tms, SecureRandom sr, ClientSessionContext clientSessionContext, ServerSessionContext serverSessionContext, String[] protocols)Initializes the parameters.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Objectclone()Returns the clone of this object.static StringgetClientKeyType(byte clientCertificateType)Similar to getServerKeyType, but returns value given TLS ClientCertificateType byte values from a CertificateRequest message for use with X509KeyManager.chooseClientAlias or X509ExtendedKeyManager.chooseEngineClientAlias.protected ClientSessionContextgetClientSessionContext()protected CTVerifiergetCTVerifier()protected static SSLParametersImplgetDefault()static X509TrustManagergetDefaultX509TrustManager()Gets the default X.509 trust manager.protected String[]getEnabledCipherSuites()protected String[]getEnabledProtocols()protected booleangetEnableSessionCreation()Returns the value indicating if the peer with this parameters allowed to cteate new SSL sessionStringgetEndpointIdentificationAlgorithm()protected booleangetNeedClientAuth()Returns the value indicating if the peer with this parameters tuned to require client authenticationprotected PSKKeyManagergetPSKKeyManager()protected SecureRandomgetSecureRandom()protected SecureRandomgetSecureRandomMember()protected ServerSessionContextgetServerSessionContext()org.conscrypt.AbstractSessionContextgetSessionContext()Returns the appropriate session context.static Set<String>getSupportedClientKeyTypes(byte[] clientCertificateTypes)Gets the supported key types for client certificates based on theClientCertificateTypevalues provided by the server.protected booleangetUseClientMode()Returns the value indicating if the parameters configured to work in client mode.protected booleangetUseSni()Returns whether connections using this SSL connection should use the TLS extension Server Name Indication (SNI).protected booleangetWantClientAuth()Returns the value indicating if the peer with this parameters tuned to request client authenticationprotected X509KeyManagergetX509KeyManager()protected X509TrustManagergetX509TrustManager()booleanisCTVerificationEnabled(String hostname)Check if SCT verification is enforced for a given hostname.voidsetCTVerificationEnabled(boolean enabled)voidsetCTVerifier(CTVerifier verifier)protected voidsetEnabledCipherSuites(String[] cipherSuites)Sets the enabled cipher suites after filtering through OpenSSL.protected voidsetEnabledProtocols(String[] protocols)Sets the set of available protocols for use in SSL connection.protected voidsetEnableSessionCreation(boolean flag)Allows/disallows the peer holding this parameters to create new SSL sessionvoidsetEndpointIdentificationAlgorithm(String endpointIdentificationAlgorithm)protected voidsetNeedClientAuth(boolean need)Tunes the peer holding this parameters to require client authenticationvoidsetOCSPResponse(byte[] response)voidsetSCTExtension(byte[] extension)protected voidsetUseClientMode(boolean mode)Tunes the peer holding this parameters to work in client mode.protected voidsetUseSni(boolean flag)Whether connections using this SSL connection should use the TLS extension Server Name Indication (SNI).protected voidsetWantClientAuth(boolean want)Tunes the peer holding this parameters to request client authentication
-
-
-
Constructor Detail
-
SSLParametersImpl
protected SSLParametersImpl(KeyManager[] kms, TrustManager[] tms, SecureRandom sr, ClientSessionContext clientSessionContext, ServerSessionContext serverSessionContext, String[] protocols) throws KeyManagementException
Initializes the parameters. Naturally this constructor is used in SSLContextImpl.engineInit method which directly passes its parameters. In other words this constructor holds all the functionality provided by SSLContext.init method. SeeSSLContext.init(KeyManager[],TrustManager[], SecureRandom)for more information- Throws:
KeyManagementException
-
-
Method Detail
-
getDefault
protected static SSLParametersImpl getDefault() throws KeyManagementException
- Throws:
KeyManagementException
-
getSessionContext
public org.conscrypt.AbstractSessionContext getSessionContext()
Returns the appropriate session context.
-
getServerSessionContext
protected ServerSessionContext getServerSessionContext()
- Returns:
- server session context
-
getClientSessionContext
protected ClientSessionContext getClientSessionContext()
- Returns:
- client session context
-
getX509KeyManager
protected X509KeyManager getX509KeyManager()
- Returns:
- X.509 key manager or
nullfor none.
-
getPSKKeyManager
protected PSKKeyManager getPSKKeyManager()
- Returns:
- Pre-Shared Key (PSK) key manager or
nullfor none.
-
getX509TrustManager
protected X509TrustManager getX509TrustManager()
- Returns:
- X.509 trust manager or
nullfor none.
-
getSecureRandom
protected SecureRandom getSecureRandom()
- Returns:
- secure random
-
getSecureRandomMember
protected SecureRandom getSecureRandomMember()
- Returns:
- the secure random member reference, even it is null
-
getCTVerifier
protected CTVerifier getCTVerifier()
- Returns:
- certificate transparency verifier
-
getEnabledCipherSuites
protected String[] getEnabledCipherSuites()
- Returns:
- the names of enabled cipher suites
-
setEnabledCipherSuites
protected void setEnabledCipherSuites(String[] cipherSuites)
Sets the enabled cipher suites after filtering through OpenSSL.
-
getEnabledProtocols
protected String[] getEnabledProtocols()
- Returns:
- the set of enabled protocols
-
setEnabledProtocols
protected void setEnabledProtocols(String[] protocols)
Sets the set of available protocols for use in SSL connection.- Parameters:
protocols- String[]
-
setUseClientMode
protected void setUseClientMode(boolean mode)
Tunes the peer holding this parameters to work in client mode.- Parameters:
mode- if the peer is configured to work in client mode
-
getUseClientMode
protected boolean getUseClientMode()
Returns the value indicating if the parameters configured to work in client mode.
-
setNeedClientAuth
protected void setNeedClientAuth(boolean need)
Tunes the peer holding this parameters to require client authentication
-
getNeedClientAuth
protected boolean getNeedClientAuth()
Returns the value indicating if the peer with this parameters tuned to require client authentication
-
setWantClientAuth
protected void setWantClientAuth(boolean want)
Tunes the peer holding this parameters to request client authentication
-
getWantClientAuth
protected boolean getWantClientAuth()
Returns the value indicating if the peer with this parameters tuned to request client authentication
-
setEnableSessionCreation
protected void setEnableSessionCreation(boolean flag)
Allows/disallows the peer holding this parameters to create new SSL session
-
getEnableSessionCreation
protected boolean getEnableSessionCreation()
Returns the value indicating if the peer with this parameters allowed to cteate new SSL session
-
setUseSni
protected void setUseSni(boolean flag)
Whether connections using this SSL connection should use the TLS extension Server Name Indication (SNI).
-
getUseSni
protected boolean getUseSni()
Returns whether connections using this SSL connection should use the TLS extension Server Name Indication (SNI).
-
setCTVerifier
public void setCTVerifier(CTVerifier verifier)
-
setCTVerificationEnabled
public void setCTVerificationEnabled(boolean enabled)
-
setSCTExtension
public void setSCTExtension(byte[] extension)
-
setOCSPResponse
public void setOCSPResponse(byte[] response)
-
clone
protected Object clone()
Returns the clone of this object.
-
getDefaultX509TrustManager
public static X509TrustManager getDefaultX509TrustManager() throws KeyManagementException
Gets the default X.509 trust manager.TODO: Move this to a published API under dalvik.system.
- Throws:
KeyManagementException
-
getEndpointIdentificationAlgorithm
public String getEndpointIdentificationAlgorithm()
-
setEndpointIdentificationAlgorithm
public void setEndpointIdentificationAlgorithm(String endpointIdentificationAlgorithm)
-
getClientKeyType
public static String getClientKeyType(byte clientCertificateType)
Similar to getServerKeyType, but returns value given TLS ClientCertificateType byte values from a CertificateRequest message for use with X509KeyManager.chooseClientAlias or X509ExtendedKeyManager.chooseEngineClientAlias.Visible for testing.
-
getSupportedClientKeyTypes
public static Set<String> getSupportedClientKeyTypes(byte[] clientCertificateTypes)
Gets the supported key types for client certificates based on theClientCertificateTypevalues provided by the server.- Parameters:
clientCertificateTypes-ClientCertificateTypevalues provided by the server. See https://www.ietf.org/assignments/tls-parameters/tls-parameters.xml.- Returns:
- supported key types that can be used in
X509KeyManager.chooseClientAliasandX509ExtendedKeyManager.chooseEngineClientAlias. Visible for testing.
-
isCTVerificationEnabled
public boolean isCTVerificationEnabled(String hostname)
Check if SCT verification is enforced for a given hostname. SCT Verification is enabled usingSecurityproperties. The "conscrypt.ct.enable" property must be true, as well as a per domain property. The reverse notation of the domain name, prefixed with "conscrypt.ct.enforce." is used as the property name. Basic globbing is also supported. For example, for the domain foo.bar.com, the following properties will be looked up, in order of precedence. - conscrypt.ct.enforce.com.bar.foo - conscrypt.ct.enforce.com.bar.* - conscrypt.ct.enforce.com.* - conscrypt.ct.enforce.*
-
-