SSLContext
classin packageklyn.net.ssl
public class SSLContext extends Object:
Immutable TLS client context inspired by Java's `SSLContext`.
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)
Fields
| Modifier and Type |
Member |
Description |
| public |
SSLContext(verifyPeer |
Creates a TLS context. |
| public readonly |
caFile |
Optional CA certificate file in PEM format. |
| public readonly |
caPath |
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 |
maxVersion |
Optional maximum TLS version, for example `TLSv1. |
| public readonly |
minVersion |
Optional minimum TLS version, for example `TLSv1. |
| public readonly |
verifyPeer |
True when peer certificates and host names must be verified. |
Methods
| Modifier and Type |
Member |
Description |
| public static |
clientDefault |
Returns the default verified client context. |
| public |
copy |
Returns a copy of this context. |
| public static |
insecure |
Returns an insecure context that disables peer verification. |
| public |
openSocket |
Opens a TLS socket using this context. |
| public |
trustAll |
Returns a copy that trusts all peers. |
| public |
withCaFile |
Returns a copy with a custom CA certificate file. |
| public |
withCaPath |
Returns a copy with a custom CA certificate directory. |
| public |
withClientCertificate |
Returns a copy with a client certificate and private key. |
| public |
withTlsVersions |
Returns a copy with minimum and optional maximum TLS versions. |