SSLContext
classin packageklyn.net.ssl
public class SSLContext extends Object:
└ SSLContext
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
SSLContext(verifyPeer as Boolean = true,
Creates a TLS context.
public readonly caFile
caFile as String
Optional CA certificate file in PEM format.
public readonly caPath
caPath as String
Optional CA certificate folder.
public readonly clientCertificateFile
clientCertificateFile as String
Optional client certificate file in PEM format.
public readonly clientPrivateKeyFile
clientPrivateKeyFile as String
Optional client private key file in PEM format.
public readonly maxVersion
maxVersion as String
Optional maximum TLS version, for example `TLSv1.
public readonly minVersion
minVersion as String
Optional minimum TLS version, for example `TLSv1.
public readonly verifyPeer
verifyPeer as Boolean
True when peer certificates and host names must be verified.
Properties inherited from Object: type
Methods
Modifier and Type Member Description
public static clientDefault
clientDefault() as SSLContext:
Returns the default verified client context.
public copy
copy() as SSLContext:
Returns a copy of this context.
public static insecure
insecure() as SSLContext:
Returns an insecure context that disables peer verification.
public openSocket
openSocket(host as String, port as Int) as SSLSocket throws SSLException:
Opens a TLS socket using this context.
public trustAll
trustAll() as SSLContext:
Returns a copy that trusts all peers.
public withCaFile
withCaFile(value as Object) as SSLContext throws SSLException:
Returns a copy with a custom CA certificate file.
public withCaPath
withCaPath(value as Object) as SSLContext throws SSLException:
Returns a copy with a custom CA certificate directory.
public withClientCertificate
withClientCertificate(certificatePath as Object, privateKeyPath as Object) as SSLContext throws SSLException:
Returns a copy with a client certificate and private key.
public withTlsVersions
withTlsVersions(minVersion as String, maxVersion as String = "") as SSLContext:
Returns a copy with minimum and optional maximum TLS versions.
Methods inherited from Object: fromJson, toDict, toJson, toString, toXml