net / org.apache.tuweni.net.tls / TLS

TLS

class TLS (source)

Common utilities for TLS.

This class depends upon the BouncyCastle library being available and added as a java.security.Provider. See https://www.bouncycastle.org/wiki/display/JA1/Provider+Installation.

BouncyCastle can be included using the gradle dependencies org.bouncycastle:bcprov-jdk15on and org.bouncycastle:bcpkix-jdk15on.

Functions

certificateFingerprint

static fun certificateFingerprint(certificate: Path): ByteArray

Calculate the fingerprint for a PEM-encoded certificate.

static fun certificateFingerprint(certificate: Certificate): ByteArray

Calculate the fingerprint for certificate.

certificateHexFingerprint

static fun certificateHexFingerprint(certificate: Path): String

Calculate the fingerprint for a PEM-encoded certificate.

static fun certificateHexFingerprint(certificate: Certificate): String

Calculate the fingerprint for certificate.

createSelfSignedCertificateIfMissing

static fun createSelfSignedCertificateIfMissing(key: Path, certificate: Path): Boolean

Create a self-signed certificate, if it is not already present.

If both the key or the certificate file are missing, they will be re-created as a self-signed certificate.

readPemFile

static fun readPemFile(certificate: Path): ByteArray

Read a PEM-encoded file.