/** * Returns the {@link PrivateKey} of the self-signed certificate. */ public PrivateKey privateKey() { ensureCertificate(); return certificate.key(); }
public static X509Certificate generate(String fqdn) throws IOException, CertificateException, NoSuchProviderException, NoSuchAlgorithmException, InvalidKeyException, SignatureException { SelfSignedCertificate selfSignedCertificate = new SelfSignedCertificate(fqdn, NOT_BEFORE, NOT_AFTER); return new X509Certificate(fqdn, selfSignedCertificate.key(), selfSignedCertificate.cert()); } }
sslContext = SslContextBuilder.forServer(ssc.key(), ssc.cert()).build();
} else { SelfSignedCertificate ssc = new SelfSignedCertificate(); privateKey = ssc.key(); chain = new X509Certificate[] {ssc.cert()};
public SelfSignedServerCertificateProvider() { SelfSignedCertificate ssc = Try.of(()->new SelfSignedCertificate(NAME)).get(); this.serverCertificate = new ServerCertificate(new X509Certificate[] {ssc.cert()}, ssc.key()); }