public final class TlsContextOptions extends CrtResource
| Modifier and Type | Class and Description |
|---|---|
static class |
TlsContextOptions.TlsVersions |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
canReleaseReferencesImmediately()
Determines whether a resource releases its dependencies at the same time the native handle is released or if it waits.
|
static TlsContextOptions |
createDefaultClient()
Helper which creates a default set of TLS options for the current platform
|
static TlsContextOptions |
createDefaultServer()
Helper which creates a default set of TLS options for the current platform
|
static TlsContextOptions |
createWithMTLS(String certificate,
String privateKey)
Helper which creates TLS options using a certificate and private key
|
static TlsContextOptions |
createWithMTLSFromPath(String certificatePath,
String privateKeyPath)
Helper which creates TLS options using a certificate and private key
|
static TlsContextOptions |
createWithMTLSPkcs12(String pkcs12Path,
String pkcs12Password)
OSX only - Helper which creates TLS options using PKCS12
|
void |
initMTLS(String certificate,
String privateKey)
Sets the certificate/key pair that identifies this TLS host.
|
void |
initMTLSFromPath(String certificatePath,
String privateKeyPath)
Sets the path to the certificate that identifies this TLS host.
|
void |
initMTLSPkcs12(String pkcs12Path,
String pkcs12Password)
OSX only - Initializes MTLS with PKCS12 file and password
|
static boolean |
isAlpnSupported()
Returns whether or not ALPN is supported on the current platform
|
static boolean |
isCipherPreferenceSupported(TlsCipherPreference cipherPref)
Returns whether or not the current platform can be configured to a specific TlsCipherPreference.
|
void |
overrideDefaultTrustStore(String caRoot)
Helper function to provide a TlsContext-local trust store
|
void |
overrideDefaultTrustStoreFromPath(String caPath,
String caFile)
Helper function to provide a TlsContext-local trust store
|
protected void |
releaseNativeHandle()
Frees the native resources associated with this instance
|
void |
setAlpnList(String alpn)
Sets the ALPN protocol list that will be provided when a TLS connection
starts
|
void |
setCipherPreference(TlsCipherPreference cipherPref)
Sets the TLS Cipher Preferences that can be negotiated and used during the TLS Connection.
|
void |
setMinimumTlsVersion(TlsContextOptions.TlsVersions version)
Sets the minimum acceptable TLS version that the
TlsContext will allow. |
void |
setVerifyPeer(boolean verify)
Set whether or not the peer should be verified.
|
TlsContextOptions |
withAlpnList(String alpnList) |
TlsContextOptions |
withCipherPreference(TlsCipherPreference cipherPref)
.with() methods
|
TlsContextOptions |
withMinimumTlsVersion(TlsContextOptions.TlsVersions version) |
acquireNativeHandle, addReferenceTo, close, collectNativeResources, getNativeHandle, isNativeResource, isNull, logNativeResources, releaseReferences, waitForNoResourcesprotected boolean canReleaseReferencesImmediately()
canReleaseReferencesImmediately in class CrtResourceprotected void releaseNativeHandle()
releaseNativeHandle in class CrtResourcepublic void setMinimumTlsVersion(TlsContextOptions.TlsVersions version)
TlsContext will allow. Not compatible with
setCipherPreference() API.version - Select from TlsVersions, a good default is TlsVersions.TLS_VER_SYS_DEFAULTS
as this will update if the OS TLS is updatedpublic void setAlpnList(String alpn)
alpn - The ALPN protocol to use, e.g. "x-amzn-mqtt-ca"public void setCipherPreference(TlsCipherPreference cipherPref)
cipherPref - The Cipher Preference to usepublic void initMTLSFromPath(String certificatePath, String privateKeyPath)
certificatePath - Path to PEM format certificateprivateKeyPath - Path to PEM format private keypublic void initMTLS(String certificate, String privateKey) throws IllegalArgumentException
certificate - PEM armored certificateprivateKey - PEM armored private keyIllegalArgumentException - If the certificate or privateKey are not in PEM format or if they contain chainspublic void initMTLSPkcs12(String pkcs12Path, String pkcs12Password)
pkcs12Path - Path to PKCS12 filepkcs12Password - PKCS12 passwordpublic void setVerifyPeer(boolean verify)
verify - true to verify peers, false to skip verificationpublic static boolean isAlpnSupported()
public static boolean isCipherPreferenceSupported(TlsCipherPreference cipherPref)
cipherPref - The TlsCipherPreference to checkpublic void overrideDefaultTrustStoreFromPath(String caPath, String caFile)
caPath - Path to the local trust store. Can be null.caFile - Path to the root certificate. Must be in PEM format.public void overrideDefaultTrustStore(String caRoot) throws IllegalArgumentException
caRoot - Buffer containing the root certificate chain. Must be in PEM format.IllegalArgumentExceptionpublic static TlsContextOptions createDefaultClient() throws CrtRuntimeException
CrtRuntimeException - @see TlsContextOptions.TlsContextOptions()public static TlsContextOptions createDefaultServer() throws CrtRuntimeException
CrtRuntimeException - @see TlsContextOptions.TlsContextOptions()public static TlsContextOptions createWithMTLSFromPath(String certificatePath, String privateKeyPath) throws CrtRuntimeException
certificatePath - Path to a PEM format certificateprivateKeyPath - Path to a PEM format private keyCrtRuntimeException - @see #constructor()public static TlsContextOptions createWithMTLS(String certificate, String privateKey) throws CrtRuntimeException, IllegalArgumentException
certificate - String containing a PEM format certificateprivateKey - String containing a PEM format private keyCrtRuntimeException - @see #constructor()IllegalArgumentException - If either PEM fails to parsepublic static TlsContextOptions createWithMTLSPkcs12(String pkcs12Path, String pkcs12Password) throws CrtRuntimeException
pkcs12Path - The path to a PKCS12 file @see #setPkcs12Path(String)pkcs12Password - The PKCS12 password @see #setPkcs12Password(String)CrtRuntimeException - @see #constructor()public TlsContextOptions withCipherPreference(TlsCipherPreference cipherPref)
public TlsContextOptions withMinimumTlsVersion(TlsContextOptions.TlsVersions version)
public TlsContextOptions withAlpnList(String alpnList)
Copyright © 2019. All rights reserved.