public final class OpenSSLEngineImpl extends SSLEngine implements NativeCrypto.SSLHandshakeCallbacks, SSLParametersImpl.AliasChooser, SSLParametersImpl.PSKCallbacks
SSLEngine API using OpenSSL's non-blocking interfaces.| Constructor and Description |
|---|
OpenSSLEngineImpl(SSLParametersImpl sslParameters) |
OpenSSLEngineImpl(String host,
int port,
SSLParametersImpl sslParameters) |
| Modifier and Type | Method and Description |
|---|---|
void |
beginHandshake() |
String |
chooseClientAlias(X509KeyManager keyManager,
X500Principal[] issuers,
String[] keyTypes) |
String |
chooseClientPSKIdentity(PSKKeyManager keyManager,
String identityHint) |
String |
chooseServerAlias(X509KeyManager keyManager,
String keyType) |
String |
chooseServerPSKIdentityHint(PSKKeyManager keyManager) |
void |
clientCertificateRequested(byte[] keyTypeBytes,
byte[][] asn1DerEncodedPrincipals)
Called on an SSL client when the server requests (or
requires a certificate).
|
int |
clientPSKKeyRequested(String identityHint,
byte[] identity,
byte[] key)
Gets the key to be used in client mode for this connection in Pre-Shared Key (PSK) key
exchange.
|
void |
closeInbound() |
void |
closeOutbound() |
protected void |
finalize() |
byte[] |
getAlpnSelectedProtocol()
Returns the protocol agreed upon by client and server, or
null if no protocol was
agreed upon. |
Runnable |
getDelegatedTask() |
String[] |
getEnabledCipherSuites() |
String[] |
getEnabledProtocols() |
boolean |
getEnableSessionCreation() |
SSLSession |
getHandshakeSession() |
SSLEngineResult.HandshakeStatus |
getHandshakeStatus() |
boolean |
getNeedClientAuth() |
byte[] |
getNpnSelectedProtocol()
Returns null always for backward compatibility.
|
SecretKey |
getPSKKey(PSKKeyManager keyManager,
String identityHint,
String identity) |
SSLSession |
getSession() |
String[] |
getSupportedCipherSuites() |
String[] |
getSupportedProtocols() |
boolean |
getUseClientMode() |
boolean |
getWantClientAuth() |
boolean |
isInboundDone() |
boolean |
isOutboundDone() |
void |
onSSLStateChange(int type,
int val)
Called when SSL state changes.
|
int |
serverPSKKeyRequested(String identityHint,
String identity,
byte[] key)
Gets the key to be used in server mode for this connection in Pre-Shared Key (PSK) key
exchange.
|
void |
setAlpnProtocols(byte[] alpnProtocols)
Sets the list of protocols this peer is interested in.
|
void |
setEnabledCipherSuites(String[] suites) |
void |
setEnabledProtocols(String[] protocols) |
void |
setEnableSessionCreation(boolean flag) |
void |
setNeedClientAuth(boolean need) |
void |
setNpnProtocols(byte[] npnProtocols)
This method does nothing and is kept for backward compatibility.
|
void |
setUseClientMode(boolean mode) |
void |
setUseSessionTickets(boolean useSessionTickets)
This method enables session ticket support.
|
void |
setWantClientAuth(boolean want) |
SSLEngineResult |
unwrap(ByteBuffer[] srcs,
ByteBuffer[] dsts) |
SSLEngineResult |
unwrap(ByteBuffer[] srcs,
int srcsOffset,
int srcsLength,
ByteBuffer[] dsts,
int dstsOffset,
int dstsLength) |
SSLEngineResult |
unwrap(ByteBuffer src,
ByteBuffer dst) |
SSLEngineResult |
unwrap(ByteBuffer src,
ByteBuffer[] dsts) |
SSLEngineResult |
unwrap(ByteBuffer src,
ByteBuffer[] dsts,
int offset,
int length) |
void |
verifyCertificateChain(long[] certRefs,
String authMethod)
Verify that we trust the certificate chain is trusted.
|
SSLEngineResult |
wrap(ByteBuffer[] srcs,
int offset,
int length,
ByteBuffer dst) |
SSLEngineResult |
wrap(ByteBuffer src,
ByteBuffer dst) |
getPeerHost, getPeerPort, getSSLParameters, setSSLParameters, wrappublic OpenSSLEngineImpl(SSLParametersImpl sslParameters)
public OpenSSLEngineImpl(String host, int port, SSLParametersImpl sslParameters)
public void beginHandshake()
throws SSLException
beginHandshake in class SSLEngineSSLExceptionpublic void closeInbound()
throws SSLException
closeInbound in class SSLEngineSSLExceptionpublic void closeOutbound()
closeOutbound in class SSLEnginepublic Runnable getDelegatedTask()
getDelegatedTask in class SSLEnginepublic String[] getEnabledCipherSuites()
getEnabledCipherSuites in class SSLEnginepublic String[] getEnabledProtocols()
getEnabledProtocols in class SSLEnginepublic boolean getEnableSessionCreation()
getEnableSessionCreation in class SSLEnginepublic SSLEngineResult.HandshakeStatus getHandshakeStatus()
getHandshakeStatus in class SSLEnginepublic boolean getNeedClientAuth()
getNeedClientAuth in class SSLEnginepublic SSLSession getSession()
getSession in class SSLEnginepublic String[] getSupportedCipherSuites()
getSupportedCipherSuites in class SSLEnginepublic String[] getSupportedProtocols()
getSupportedProtocols in class SSLEnginepublic boolean getUseClientMode()
getUseClientMode in class SSLEnginepublic boolean getWantClientAuth()
getWantClientAuth in class SSLEnginepublic boolean isInboundDone()
isInboundDone in class SSLEnginepublic boolean isOutboundDone()
isOutboundDone in class SSLEnginepublic void setEnabledCipherSuites(String[] suites)
setEnabledCipherSuites in class SSLEnginepublic void setEnabledProtocols(String[] protocols)
setEnabledProtocols in class SSLEnginepublic void setEnableSessionCreation(boolean flag)
setEnableSessionCreation in class SSLEnginepublic void setNeedClientAuth(boolean need)
setNeedClientAuth in class SSLEnginepublic void setUseClientMode(boolean mode)
setUseClientMode in class SSLEnginepublic void setWantClientAuth(boolean want)
setWantClientAuth in class SSLEnginepublic SSLEngineResult unwrap(ByteBuffer src, ByteBuffer dst) throws SSLException
unwrap in class SSLEngineSSLExceptionpublic SSLEngineResult unwrap(ByteBuffer src, ByteBuffer[] dsts) throws SSLException
unwrap in class SSLEngineSSLExceptionpublic SSLEngineResult unwrap(ByteBuffer src, ByteBuffer[] dsts, int offset, int length) throws SSLException
unwrap in class SSLEngineSSLExceptionpublic SSLEngineResult unwrap(ByteBuffer[] srcs, ByteBuffer[] dsts) throws SSLException
SSLExceptionpublic SSLEngineResult unwrap(ByteBuffer[] srcs, int srcsOffset, int srcsLength, ByteBuffer[] dsts, int dstsOffset, int dstsLength) throws SSLException
SSLExceptionpublic final SSLEngineResult wrap(ByteBuffer src, ByteBuffer dst) throws SSLException
wrap in class SSLEngineSSLExceptionpublic SSLEngineResult wrap(ByteBuffer[] srcs, int offset, int length, ByteBuffer dst) throws SSLException
wrap in class SSLEngineSSLExceptionpublic int clientPSKKeyRequested(String identityHint, byte[] identity, byte[] key)
NativeCrypto.SSLHandshakeCallbacksclientPSKKeyRequested in interface NativeCrypto.SSLHandshakeCallbacksidentityHint - PSK identity hint provided by the server or null if no hint
provided.identity - buffer to be populated with PSK identity (NULL-terminated modified UTF-8)
by this method. This identity will be provided to the server.key - buffer to be populated with key material by this method.key buffer or 0 if an
error occurred in which case the handshake will be aborted.public int serverPSKKeyRequested(String identityHint, String identity, byte[] key)
NativeCrypto.SSLHandshakeCallbacksserverPSKKeyRequested in interface NativeCrypto.SSLHandshakeCallbacksidentityHint - PSK identity hint provided by this server to the client or
null if no hint was provided.identity - PSK identity provided by the client.key - buffer to be populated with key material by this method.key buffer or 0 if an
error occurred in which case the handshake will be aborted.public void onSSLStateChange(int type,
int val)
NativeCrypto.SSLHandshakeCallbacksonSSLStateChange in interface NativeCrypto.SSLHandshakeCallbackspublic void verifyCertificateChain(long[] certRefs,
String authMethod)
throws CertificateException
NativeCrypto.SSLHandshakeCallbacksverifyCertificateChain in interface NativeCrypto.SSLHandshakeCallbackscertRefs - chain of X.509 certificate referencesauthMethod - auth algorithm nameCertificateException - if the certificate is untrustedpublic void clientCertificateRequested(byte[] keyTypeBytes,
byte[][] asn1DerEncodedPrincipals)
throws CertificateEncodingException,
SSLException
NativeCrypto.SSLHandshakeCallbacksclientCertificateRequested in interface NativeCrypto.SSLHandshakeCallbackskeyTypeBytes - key types supported by the server,
convertible to strings with #keyTypeasn1DerEncodedPrincipals - CAs known to the serverCertificateEncodingExceptionSSLExceptionprotected void finalize()
throws Throwable
public SSLSession getHandshakeSession()
getHandshakeSession in class SSLEnginepublic String chooseServerAlias(X509KeyManager keyManager, String keyType)
chooseServerAlias in interface SSLParametersImpl.AliasChooserpublic String chooseClientAlias(X509KeyManager keyManager, X500Principal[] issuers, String[] keyTypes)
chooseClientAlias in interface SSLParametersImpl.AliasChooserpublic String chooseServerPSKIdentityHint(PSKKeyManager keyManager)
chooseServerPSKIdentityHint in interface SSLParametersImpl.PSKCallbackspublic String chooseClientPSKIdentity(PSKKeyManager keyManager, String identityHint)
chooseClientPSKIdentity in interface SSLParametersImpl.PSKCallbackspublic SecretKey getPSKKey(PSKKeyManager keyManager, String identityHint, String identity)
getPSKKey in interface SSLParametersImpl.PSKCallbackspublic void setUseSessionTickets(boolean useSessionTickets)
useSessionTickets - True to enable session ticketspublic void setNpnProtocols(byte[] npnProtocols)
public void setAlpnProtocols(byte[] alpnProtocols)
null, no
protocols will be used.alpnProtocols - a non-empty array of protocol names. From SSL_select_next_proto, "vector
of 8-bit, length prefixed byte strings. The length byte itself is not included in the length.
A byte string of length 0 is invalid. No byte string may be truncated.".public byte[] getNpnSelectedProtocol()
public byte[] getAlpnSelectedProtocol()
null if no protocol was
agreed upon.