Package org.conscrypt
Class Conscrypt
- java.lang.Object
-
- org.conscrypt.Conscrypt
-
public final class Conscrypt extends java.lang.ObjectCore API for creating and configuring all Conscrypt types.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classConscrypt.ProviderBuilderstatic classConscrypt.Version
-
Field Summary
Fields Modifier and Type Field Description private static Conscrypt.VersionVERSION
-
Constructor Summary
Constructors Modifier Constructor Description privateConscrypt()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static voidcheckAvailability()Checks that the Conscrypt support is available for the system.static byte[]exportKeyingMaterial(javax.net.ssl.SSLEngine engine, java.lang.String label, byte[] context, int length)Exports a value derived from the TLS master secret as described in RFC 5705.static byte[]exportKeyingMaterial(javax.net.ssl.SSLSocket socket, java.lang.String label, byte[] context, int length)Exports a value derived from the TLS master secret as described in RFC 5705.static java.lang.StringgetApplicationProtocol(javax.net.ssl.SSLEngine engine)Returns the ALPN protocol agreed upon by client and server.static java.lang.StringgetApplicationProtocol(javax.net.ssl.SSLSocket socket)Returns the ALPN protocol agreed upon by client and server.static java.lang.String[]getApplicationProtocols(javax.net.ssl.SSLEngine engine)Gets the application-layer protocols (ALPN) in prioritization order.static java.lang.String[]getApplicationProtocols(javax.net.ssl.SSLSocket socket)Gets the application-layer protocols (ALPN) in prioritization order.static byte[]getChannelId(javax.net.ssl.SSLEngine engine)Gets the TLS Channel ID for the given server-side engine.static byte[]getChannelId(javax.net.ssl.SSLSocket socket)Gets the TLS Channel ID for the given server-side socket.static ConscryptHostnameVerifiergetDefaultHostnameVerifier(javax.net.ssl.TrustManager trustManager)Returns the currently-set default hostname verifier for Conscrypt trust managers.static javax.net.ssl.X509TrustManagergetDefaultX509TrustManager()Gets the default X.509 trust manager.static java.lang.StringgetHostname(javax.net.ssl.SSLEngine engine)Returns either the hostname supplied during socket creation or viasetHostname(SSLEngine, String).static java.lang.StringgetHostname(javax.net.ssl.SSLSocket socket)Returns either the hostname supplied during socket creation or viasetHostname(SSLSocket, String).static java.lang.StringgetHostnameOrIP(javax.net.ssl.SSLSocket socket)This method attempts to create a textual representation of the peer host or IP.static ConscryptHostnameVerifiergetHostnameVerifier(javax.net.ssl.TrustManager trustManager)Returns the currently-set hostname verifier for the given trust manager.static byte[]getTlsUnique(javax.net.ssl.SSLEngine engine)Returns the tls-unique channel binding value for this connection, per RFC 5929.static byte[]getTlsUnique(javax.net.ssl.SSLSocket socket)Returns the tls-unique channel binding value for this connection, per RFC 5929.static booleanisAvailable()Returnstrueif the Conscrypt native library has been successfully loaded.static booleanisConscrypt(java.security.Provider provider)Indicates whether the givenProviderwas created by this distribution of Conscrypt.static booleanisConscrypt(javax.net.ssl.SSLContext context)Indicates whether the givenSSLContextwas created by this distribution of Conscrypt.static booleanisConscrypt(javax.net.ssl.SSLEngine engine)Indicates whether the givenSSLEnginewas created by this distribution of Conscrypt.static booleanisConscrypt(javax.net.ssl.SSLServerSocketFactory factory)Indicates whether the givenSSLServerSocketFactorywas created by this distribution of Conscrypt.static booleanisConscrypt(javax.net.ssl.SSLSocket socket)Indicates whether the givenSSLSocketwas created by this distribution of Conscrypt.static booleanisConscrypt(javax.net.ssl.SSLSocketFactory factory)Indicates whether the givenSSLSocketFactorywas created by this distribution of Conscrypt.static booleanisConscrypt(javax.net.ssl.TrustManager trustManager)Indicates whether the givenTrustManagerwas created by this distribution of Conscrypt.static intmaxEncryptedPacketLength()Returns the maximum length (in bytes) of an encrypted packet.static intmaxSealOverhead(javax.net.ssl.SSLEngine engine)Returns the maximum overhead, in bytes, of sealing a record with SSL.static javax.net.ssl.SSLContextSpinewPreferredSSLContextSpi()Constructs a new instance of the preferredSSLContextSpi.static java.security.ProvidernewProvider()Constructs a newProviderwith the default name.static java.security.ProvidernewProvider(java.lang.String providerName)Deprecated.UsenewProviderBuilder()instead.static Conscrypt.ProviderBuildernewProviderBuilder()static voidsetApplicationProtocols(javax.net.ssl.SSLEngine engine, java.lang.String[] protocols)Sets the application-layer protocols (ALPN) in prioritization order.static voidsetApplicationProtocols(javax.net.ssl.SSLSocket socket, java.lang.String[] protocols)Sets the application-layer protocols (ALPN) in prioritization order.static voidsetApplicationProtocolSelector(javax.net.ssl.SSLEngine engine, ApplicationProtocolSelector selector)Sets an application-provided ALPN protocol selector.static voidsetApplicationProtocolSelector(javax.net.ssl.SSLSocket socket, ApplicationProtocolSelector selector)Sets an application-provided ALPN protocol selector.static voidsetBufferAllocator(javax.net.ssl.SSLEngine engine, BufferAllocator bufferAllocator)Provides the given engine with the provided bufferAllocator.static voidsetBufferAllocator(javax.net.ssl.SSLSocket socket, BufferAllocator bufferAllocator)Provides the given socket with the provided bufferAllocator.static voidsetChannelIdEnabled(javax.net.ssl.SSLEngine engine, boolean enabled)Enables/disables TLS Channel ID for the given server-side engine.static voidsetChannelIdEnabled(javax.net.ssl.SSLSocket socket, boolean enabled)Enables/disables TLS Channel ID for the given server-side socket.static voidsetChannelIdPrivateKey(javax.net.ssl.SSLEngine engine, java.security.PrivateKey privateKey)Sets thePrivateKeyto be used for TLS Channel ID by this client engine.static voidsetChannelIdPrivateKey(javax.net.ssl.SSLSocket socket, java.security.PrivateKey privateKey)Sets thePrivateKeyto be used for TLS Channel ID by this client socket.static voidsetClientSessionCache(javax.net.ssl.SSLContext context, SSLClientSessionCache cache)Sets the client-side persistent cache to be used by the context.static voidsetDefaultBufferAllocator(BufferAllocator bufferAllocator)Configures the defaultBufferAllocatorto be used by all futureSSLEngineinstances from this provider.static voidsetDefaultHostnameVerifier(ConscryptHostnameVerifier verifier)Set the default hostname verifier that will be used for HTTPS endpoint identification by Conscrypt trust managers.static voidsetHandshakeListener(javax.net.ssl.SSLEngine engine, HandshakeListener handshakeListener)Sets a listener on the given engine for completion of the TLS handshakestatic voidsetHostname(javax.net.ssl.SSLEngine engine, java.lang.String hostname)This method enables Server Name Indication (SNI) and overrides the hostname supplied during engine creation.static voidsetHostname(javax.net.ssl.SSLSocket socket, java.lang.String hostname)This method enables Server Name Indication (SNI) and overrides the hostname supplied during socket creation.static voidsetHostnameVerifier(javax.net.ssl.TrustManager trustManager, ConscryptHostnameVerifier verifier)Set the hostname verifier that will be used for HTTPS endpoint identification by the given trust manager.static voidsetServerSessionCache(javax.net.ssl.SSLContext context, SSLServerSessionCache cache)Sets the server-side persistent cache to be used by the context.static voidsetUseEngineSocket(javax.net.ssl.SSLServerSocketFactory factory, boolean useEngineSocket)Configures the socket to be created for the given server socket factory instance.static voidsetUseEngineSocket(javax.net.ssl.SSLSocketFactory factory, boolean useEngineSocket)Configures the socket to be created for the given socket factory instance.static voidsetUseEngineSocketByDefault(boolean useEngineSocket)Configures the default socket to be created for all socket factory instances.static voidsetUseSessionTickets(javax.net.ssl.SSLEngine engine, boolean useSessionTickets)This method enables session ticket support.static voidsetUseSessionTickets(javax.net.ssl.SSLSocket socket, boolean useSessionTickets)This method enables session ticket support.private static AbstractConscryptEnginetoConscrypt(javax.net.ssl.SSLEngine engine)private static OpenSSLServerSocketFactoryImpltoConscrypt(javax.net.ssl.SSLServerSocketFactory factory)private static AbstractConscryptSockettoConscrypt(javax.net.ssl.SSLSocket socket)private static OpenSSLSocketFactoryImpltoConscrypt(javax.net.ssl.SSLSocketFactory factory)private static TrustManagerImpltoConscrypt(javax.net.ssl.TrustManager trustManager)static javax.net.ssl.SSLEngineResultunwrap(javax.net.ssl.SSLEngine engine, java.nio.ByteBuffer[] srcs, int srcsOffset, int srcsLength, java.nio.ByteBuffer[] dsts, int dstsOffset, int dstsLength)Exteneded unwrap method for multiple source and destination buffers.static javax.net.ssl.SSLEngineResultunwrap(javax.net.ssl.SSLEngine engine, java.nio.ByteBuffer[] srcs, java.nio.ByteBuffer[] dsts)Extended unwrap method for multiple source and destination buffers.static Conscrypt.Versionversion()Returns the version of this distribution of Conscrypt.static ConscryptHostnameVerifierwrapHostnameVerifier(javax.net.ssl.HostnameVerifier verifier)Wraps the HttpsURLConnection.HostnameVerifier into a ConscryptHostnameVerifier
-
-
-
Field Detail
-
VERSION
private static final Conscrypt.Version VERSION
-
-
Method Detail
-
isAvailable
public static boolean isAvailable()
Returnstrueif the Conscrypt native library has been successfully loaded.
-
version
public static Conscrypt.Version version()
Returns the version of this distribution of Conscrypt. If version information is unavailable, returnsnull.
-
checkAvailability
public static void checkAvailability()
Checks that the Conscrypt support is available for the system.- Throws:
java.lang.UnsatisfiedLinkError- if unavailable
-
isConscrypt
public static boolean isConscrypt(java.security.Provider provider)
Indicates whether the givenProviderwas created by this distribution of Conscrypt.
-
newProvider
public static java.security.Provider newProvider()
Constructs a newProviderwith the default name.
-
newProvider
@Deprecated public static java.security.Provider newProvider(java.lang.String providerName)
Deprecated.UsenewProviderBuilder()instead.Constructs a newProviderwith the given name.
-
newProviderBuilder
public static Conscrypt.ProviderBuilder newProviderBuilder()
-
maxEncryptedPacketLength
public static int maxEncryptedPacketLength()
Returns the maximum length (in bytes) of an encrypted packet.
-
getDefaultX509TrustManager
@ExperimentalApi public static javax.net.ssl.X509TrustManager getDefaultX509TrustManager() throws java.security.KeyManagementException
Gets the default X.509 trust manager.- Throws:
java.security.KeyManagementException
-
isConscrypt
public static boolean isConscrypt(javax.net.ssl.SSLContext context)
Indicates whether the givenSSLContextwas created by this distribution of Conscrypt.
-
newPreferredSSLContextSpi
public static javax.net.ssl.SSLContextSpi newPreferredSSLContextSpi()
Constructs a new instance of the preferredSSLContextSpi.
-
setClientSessionCache
public static void setClientSessionCache(javax.net.ssl.SSLContext context, SSLClientSessionCache cache)Sets the client-side persistent cache to be used by the context.
-
setServerSessionCache
public static void setServerSessionCache(javax.net.ssl.SSLContext context, SSLServerSessionCache cache)Sets the server-side persistent cache to be used by the context.
-
isConscrypt
public static boolean isConscrypt(javax.net.ssl.SSLSocketFactory factory)
Indicates whether the givenSSLSocketFactorywas created by this distribution of Conscrypt.
-
toConscrypt
private static OpenSSLSocketFactoryImpl toConscrypt(javax.net.ssl.SSLSocketFactory factory)
-
setUseEngineSocketByDefault
@ExperimentalApi public static void setUseEngineSocketByDefault(boolean useEngineSocket)
Configures the default socket to be created for all socket factory instances.
-
setUseEngineSocket
@ExperimentalApi public static void setUseEngineSocket(javax.net.ssl.SSLSocketFactory factory, boolean useEngineSocket)
Configures the socket to be created for the given socket factory instance.
-
isConscrypt
public static boolean isConscrypt(javax.net.ssl.SSLServerSocketFactory factory)
Indicates whether the givenSSLServerSocketFactorywas created by this distribution of Conscrypt.
-
toConscrypt
private static OpenSSLServerSocketFactoryImpl toConscrypt(javax.net.ssl.SSLServerSocketFactory factory)
-
setUseEngineSocket
@ExperimentalApi public static void setUseEngineSocket(javax.net.ssl.SSLServerSocketFactory factory, boolean useEngineSocket)
Configures the socket to be created for the given server socket factory instance.
-
isConscrypt
public static boolean isConscrypt(javax.net.ssl.SSLSocket socket)
Indicates whether the givenSSLSocketwas created by this distribution of Conscrypt.
-
toConscrypt
private static AbstractConscryptSocket toConscrypt(javax.net.ssl.SSLSocket socket)
-
setHostname
public static void setHostname(javax.net.ssl.SSLSocket socket, java.lang.String hostname)This method enables Server Name Indication (SNI) and overrides the hostname supplied during socket creation. If the hostname is not a valid SNI hostname, the SNI extension will be omitted from the handshake.- Parameters:
socket- the sockethostname- the desired SNI hostname, or null to disable
-
getHostname
public static java.lang.String getHostname(javax.net.ssl.SSLSocket socket)
Returns either the hostname supplied during socket creation or viasetHostname(SSLSocket, String). No DNS resolution is attempted before returning the hostname.
-
getHostnameOrIP
public static java.lang.String getHostnameOrIP(javax.net.ssl.SSLSocket socket)
This method attempts to create a textual representation of the peer host or IP. Does not perform a reverse DNS lookup. This is typically used during session creation.
-
setUseSessionTickets
public static void setUseSessionTickets(javax.net.ssl.SSLSocket socket, boolean useSessionTickets)This method enables session ticket support.- Parameters:
socket- the socketuseSessionTickets- True to enable session tickets
-
setChannelIdEnabled
public static void setChannelIdEnabled(javax.net.ssl.SSLSocket socket, boolean enabled)Enables/disables TLS Channel ID for the given server-side socket.This method needs to be invoked before the handshake starts.
- Parameters:
socket- the socketenabled- Whether to enable channel ID.- Throws:
java.lang.IllegalStateException- if this is a client socket or if the handshake has already started.
-
getChannelId
public static byte[] getChannelId(javax.net.ssl.SSLSocket socket) throws javax.net.ssl.SSLExceptionGets the TLS Channel ID for the given server-side socket. Channel ID is only available once the handshake completes.- Parameters:
socket- the socket- Returns:
- channel ID or
nullif not available. - Throws:
java.lang.IllegalStateException- if this is a client socket or if the handshake has not yet completed.javax.net.ssl.SSLException- if channel ID is available but could not be obtained.
-
setChannelIdPrivateKey
public static void setChannelIdPrivateKey(javax.net.ssl.SSLSocket socket, java.security.PrivateKey privateKey)Sets thePrivateKeyto be used for TLS Channel ID by this client socket.This method needs to be invoked before the handshake starts.
- Parameters:
socket- the socketprivateKey- private key (enables TLS Channel ID) ornullfor no key (disables TLS Channel ID). The private key must be an Elliptic Curve (EC) key based on the NIST P-256 curve (aka SECG secp256r1 or ANSI X9.62 prime256v1).- Throws:
java.lang.IllegalStateException- if this is a server socket or if the handshake has already started.
-
getApplicationProtocol
public static java.lang.String getApplicationProtocol(javax.net.ssl.SSLSocket socket)
Returns the ALPN protocol agreed upon by client and server.- Parameters:
socket- the socket- Returns:
- the selected protocol or
nullif no protocol was agreed upon.
-
setApplicationProtocolSelector
public static void setApplicationProtocolSelector(javax.net.ssl.SSLSocket socket, ApplicationProtocolSelector selector)Sets an application-provided ALPN protocol selector. If provided, this will override the list of protocols set bysetApplicationProtocols(SSLSocket, String[]).- Parameters:
socket- the socketselector- the ALPN protocol selector
-
setApplicationProtocols
public static void setApplicationProtocols(javax.net.ssl.SSLSocket socket, java.lang.String[] protocols)Sets the application-layer protocols (ALPN) in prioritization order.- Parameters:
socket- the socket being configuredprotocols- the protocols in descending order of preference. If empty, no protocol indications will be used. This array will be copied.- Throws:
java.lang.IllegalArgumentException- - if protocols is null, or if any element in a non-empty array is null or an empty (zero-length) string
-
getApplicationProtocols
public static java.lang.String[] getApplicationProtocols(javax.net.ssl.SSLSocket socket)
Gets the application-layer protocols (ALPN) in prioritization order.- Parameters:
socket- the socket- Returns:
- the protocols in descending order of preference, or an empty array if protocol indications are not being used. Always returns a new array.
-
getTlsUnique
public static byte[] getTlsUnique(javax.net.ssl.SSLSocket socket)
Returns the tls-unique channel binding value for this connection, per RFC 5929. This will returnnullif there is no such value available, such as if the handshake has not yet completed or this connection is closed.
-
exportKeyingMaterial
public static byte[] exportKeyingMaterial(javax.net.ssl.SSLSocket socket, java.lang.String label, byte[] context, int length) throws javax.net.ssl.SSLExceptionExports a value derived from the TLS master secret as described in RFC 5705.- Parameters:
label- the label to use in calculating the exported value. This must be an ASCII-only string.context- the application-specific context value to use in calculating the exported value. This may benullto use no application context, which is treated differently than an empty byte array.length- the number of bytes of keying material to return.- Returns:
- a value of the specified length, or
nullif the handshake has not yet completed or the connection has been closed. - Throws:
javax.net.ssl.SSLException- if the value could not be exported.
-
isConscrypt
public static boolean isConscrypt(javax.net.ssl.SSLEngine engine)
Indicates whether the givenSSLEnginewas created by this distribution of Conscrypt.
-
toConscrypt
private static AbstractConscryptEngine toConscrypt(javax.net.ssl.SSLEngine engine)
-
setBufferAllocator
@ExperimentalApi public static void setBufferAllocator(javax.net.ssl.SSLEngine engine, BufferAllocator bufferAllocator)
Provides the given engine with the provided bufferAllocator.- Throws:
java.lang.IllegalArgumentException- if the provided engine is not a Conscrypt engine.java.lang.IllegalStateException- if the provided engine has already begun its handshake.
-
setBufferAllocator
@ExperimentalApi public static void setBufferAllocator(javax.net.ssl.SSLSocket socket, BufferAllocator bufferAllocator)
Provides the given socket with the provided bufferAllocator. If the given socket is a Conscrypt socket but does not use buffer allocators, this method does nothing.- Throws:
java.lang.IllegalArgumentException- if the provided socket is not a Conscrypt socket.java.lang.IllegalStateException- if the provided socket has already begun its handshake.
-
setDefaultBufferAllocator
@ExperimentalApi public static void setDefaultBufferAllocator(BufferAllocator bufferAllocator)
Configures the defaultBufferAllocatorto be used by all futureSSLEngineinstances from this provider.
-
setHostname
public static void setHostname(javax.net.ssl.SSLEngine engine, java.lang.String hostname)This method enables Server Name Indication (SNI) and overrides the hostname supplied during engine creation.- Parameters:
engine- the enginehostname- the desired SNI hostname, ornullto disable
-
getHostname
public static java.lang.String getHostname(javax.net.ssl.SSLEngine engine)
Returns either the hostname supplied during socket creation or viasetHostname(SSLEngine, String). No DNS resolution is attempted before returning the hostname.
-
maxSealOverhead
public static int maxSealOverhead(javax.net.ssl.SSLEngine engine)
Returns the maximum overhead, in bytes, of sealing a record with SSL.
-
setHandshakeListener
public static void setHandshakeListener(javax.net.ssl.SSLEngine engine, HandshakeListener handshakeListener)Sets a listener on the given engine for completion of the TLS handshake
-
setChannelIdEnabled
public static void setChannelIdEnabled(javax.net.ssl.SSLEngine engine, boolean enabled)Enables/disables TLS Channel ID for the given server-side engine.This method needs to be invoked before the handshake starts.
- Parameters:
engine- the engineenabled- Whether to enable channel ID.- Throws:
java.lang.IllegalStateException- if this is a client engine or if the handshake has already started.
-
getChannelId
public static byte[] getChannelId(javax.net.ssl.SSLEngine engine) throws javax.net.ssl.SSLExceptionGets the TLS Channel ID for the given server-side engine. Channel ID is only available once the handshake completes.- Parameters:
engine- the engine- Returns:
- channel ID or
nullif not available. - Throws:
java.lang.IllegalStateException- if this is a client engine or if the handshake has not yet completed.javax.net.ssl.SSLException- if channel ID is available but could not be obtained.
-
setChannelIdPrivateKey
public static void setChannelIdPrivateKey(javax.net.ssl.SSLEngine engine, java.security.PrivateKey privateKey)Sets thePrivateKeyto be used for TLS Channel ID by this client engine.This method needs to be invoked before the handshake starts.
- Parameters:
engine- the engineprivateKey- private key (enables TLS Channel ID) ornullfor no key (disables TLS Channel ID). The private key must be an Elliptic Curve (EC) key based on the NIST P-256 curve (aka SECG secp256r1 or ANSI X9.62 prime256v1).- Throws:
java.lang.IllegalStateException- if this is a server engine or if the handshake has already started.
-
unwrap
public static javax.net.ssl.SSLEngineResult unwrap(javax.net.ssl.SSLEngine engine, java.nio.ByteBuffer[] srcs, java.nio.ByteBuffer[] dsts) throws javax.net.ssl.SSLExceptionExtended unwrap method for multiple source and destination buffers.- Parameters:
engine- the target engine for the unwrapsrcs- the source buffersdsts- the destination buffers- Returns:
- the result of the unwrap operation
- Throws:
javax.net.ssl.SSLException- thrown if an SSL error occurred
-
unwrap
public static javax.net.ssl.SSLEngineResult unwrap(javax.net.ssl.SSLEngine engine, java.nio.ByteBuffer[] srcs, int srcsOffset, int srcsLength, java.nio.ByteBuffer[] dsts, int dstsOffset, int dstsLength) throws javax.net.ssl.SSLExceptionExteneded unwrap method for multiple source and destination buffers.- Parameters:
engine- the target engine for the unwrap.srcs- the source bufferssrcsOffset- the offset in thesrcsarray of the first source buffersrcsLength- the number of source buffers starting atsrcsOffsetdsts- the destination buffersdstsOffset- the offset in thedstsarray of the first destination bufferdstsLength- the number of destination buffers starting atdstsOffset- Returns:
- the result of the unwrap operation
- Throws:
javax.net.ssl.SSLException- thrown if an SSL error occurred
-
setUseSessionTickets
public static void setUseSessionTickets(javax.net.ssl.SSLEngine engine, boolean useSessionTickets)This method enables session ticket support.- Parameters:
engine- the engineuseSessionTickets- True to enable session tickets
-
setApplicationProtocols
public static void setApplicationProtocols(javax.net.ssl.SSLEngine engine, java.lang.String[] protocols)Sets the application-layer protocols (ALPN) in prioritization order.- Parameters:
engine- the engine being configuredprotocols- the protocols in descending order of preference. If empty, no protocol indications will be used. This array will be copied.- Throws:
java.lang.IllegalArgumentException- - if protocols is null, or if any element in a non-empty array is null or an empty (zero-length) string
-
getApplicationProtocols
public static java.lang.String[] getApplicationProtocols(javax.net.ssl.SSLEngine engine)
Gets the application-layer protocols (ALPN) in prioritization order.- Parameters:
engine- the engine- Returns:
- the protocols in descending order of preference, or an empty array if protocol indications are not being used. Always returns a new array.
-
setApplicationProtocolSelector
public static void setApplicationProtocolSelector(javax.net.ssl.SSLEngine engine, ApplicationProtocolSelector selector)Sets an application-provided ALPN protocol selector. If provided, this will override the list of protocols set bysetApplicationProtocols(SSLEngine, String[]).- Parameters:
engine- the engineselector- the ALPN protocol selector
-
getApplicationProtocol
public static java.lang.String getApplicationProtocol(javax.net.ssl.SSLEngine engine)
Returns the ALPN protocol agreed upon by client and server.- Parameters:
engine- the engine- Returns:
- the selected protocol or
nullif no protocol was agreed upon.
-
getTlsUnique
public static byte[] getTlsUnique(javax.net.ssl.SSLEngine engine)
Returns the tls-unique channel binding value for this connection, per RFC 5929. This will returnnullif there is no such value available, such as if the handshake has not yet completed or this connection is closed.
-
exportKeyingMaterial
public static byte[] exportKeyingMaterial(javax.net.ssl.SSLEngine engine, java.lang.String label, byte[] context, int length) throws javax.net.ssl.SSLExceptionExports a value derived from the TLS master secret as described in RFC 5705.- Parameters:
label- the label to use in calculating the exported value. This must be an ASCII-only string.context- the application-specific context value to use in calculating the exported value. This may benullto use no application context, which is treated differently than an empty byte array.length- the number of bytes of keying material to return.- Returns:
- a value of the specified length, or
nullif the handshake has not yet completed or the connection has been closed. - Throws:
javax.net.ssl.SSLException- if the value could not be exported.
-
isConscrypt
public static boolean isConscrypt(javax.net.ssl.TrustManager trustManager)
Indicates whether the givenTrustManagerwas created by this distribution of Conscrypt.
-
toConscrypt
private static TrustManagerImpl toConscrypt(javax.net.ssl.TrustManager trustManager)
-
setDefaultHostnameVerifier
public static void setDefaultHostnameVerifier(ConscryptHostnameVerifier verifier)
Set the default hostname verifier that will be used for HTTPS endpoint identification by Conscrypt trust managers. Ifnull(the default), endpoint identification will use the default hostname verifier set inHttpsURLConnection.setDefaultHostnameVerifier(javax.net.ssl.HostnameVerifier).
-
getDefaultHostnameVerifier
public static ConscryptHostnameVerifier getDefaultHostnameVerifier(javax.net.ssl.TrustManager trustManager)
Returns the currently-set default hostname verifier for Conscrypt trust managers.
-
setHostnameVerifier
public static void setHostnameVerifier(javax.net.ssl.TrustManager trustManager, ConscryptHostnameVerifier verifier)Set the hostname verifier that will be used for HTTPS endpoint identification by the given trust manager. Ifnull(the default), endpoint identification will use the default hostname verifier set insetDefaultHostnameVerifier(ConscryptHostnameVerifier).- Throws:
java.lang.IllegalArgumentException- if the provided trust manager is not a Conscrypt trust manager perisConscrypt(TrustManager)
-
getHostnameVerifier
public static ConscryptHostnameVerifier getHostnameVerifier(javax.net.ssl.TrustManager trustManager)
Returns the currently-set hostname verifier for the given trust manager.- Throws:
java.lang.IllegalArgumentException- if the provided trust manager is not a Conscrypt trust manager perisConscrypt(TrustManager)- See Also:
setHostnameVerifier(TrustManager, ConscryptHostnameVerifier)
-
wrapHostnameVerifier
public static ConscryptHostnameVerifier wrapHostnameVerifier(javax.net.ssl.HostnameVerifier verifier)
Wraps the HttpsURLConnection.HostnameVerifier into a ConscryptHostnameVerifier
-
-