public class SSLContext extends Object
Immutable TLS client context.
The context stores TLS verification and certificate settings and can be reused for multiple HTTPS requests or TLS sockets.
import klyn.net.ssl
context = SSLContext.clientDefault().withTlsVersions("TLSv1.2", "TLSv1.3")
print(context.verifyPeer)| Modifier and Type | Member | Description |
|---|---|---|
| public readonly | caFilecaFile as String |
Optional CA certificate file in PEM format. |
| public readonly | caPathcaPath as String |
Optional CA certificate folder. |
| public readonly | clientCertificateFileclientCertificateFile as String |
Optional client certificate file in PEM format. |
| public readonly | clientPrivateKeyFileclientPrivateKeyFile as String |
Optional client private key file in PEM format. |
| public readonly | maxVersionmaxVersion as String |
Optional maximum TLS version, for example TLSv1.3. |
| public readonly | minVersionminVersion as String |
Optional minimum TLS version, for example TLSv1.2. |
| public readonly | verifyPeerverifyPeer as Boolean |
True when peer certificates and host names must be verified. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | SSLContext | Creates a TLS context. |
| Modifier and Type | Member | Description |
|---|---|---|
| public static | clientDefaultclientDefault() as SSLContext |
Returns the default verified client context. |
| public | copycopy() as SSLContext |
Returns a copy of this context. |
| public static | insecureinsecure() as SSLContext |
Returns an insecure context that disables peer verification. |
| public | openSocketopenSocket(host as String, port as Int) as SSLSocket throws SSLException |
Opens a TLS socket using this context. |
| public | trustAlltrustAll() as SSLContext |
Returns a copy that trusts all peers. |
| public | withCaFilewithCaFile(value as Object) as SSLContext throws SSLException |
Returns a copy with a custom CA certificate file. |
| public | withCaPathwithCaPath(value as Object) as SSLContext throws SSLException |
Returns a copy with a custom CA certificate directory. |
| public | withClientCertificatewithClientCertificate(certificatePath as Object, privateKeyPath as Object) as SSLContext throws SSLException |
Returns a copy with a client certificate and private key. |
| public | withTlsVersionswithTlsVersions(minVersion as String, maxVersion as String = "") as SSLContext |
Returns a copy with minimum and optional maximum TLS versions. |