private SslContext newSslContext(CacheKey key) {
        final SslContextMode mode = key.mode();
        final TlsKeyPair tlsKeyPair = key.tlsKeyPair();
        final List<X509Certificate> trustedCerts = key.trustedCertificates();
        if (mode == SslContextMode.SERVER) {
            assert tlsKeyPair != null;
            return createSslContext(
                    () -> {
                        final SslContextBuilder contextBuilder = SslContextBuilder.forServer(
                                tlsKeyPair.privateKey(),
                                tlsKeyPair.certificateChain());
                        if (!trustedCerts.isEmpty()) {
                            contextBuilder.trustManager(trustedCerts);
                        }
                        applyTlsConfig(contextBuilder);
                        return contextBuilder;
                    },
                    false, engineType, allowsUnsafeCiphers,
                    null, null);
        } else {
            final boolean forceHttp1 = mode == SslContextMode.CLIENT_HTTP1_ONLY;
            return createSslContext(
                    () -> {
                        final SslContextBuilder contextBuilder = SslContextBuilder.forClient();
                        if (tlsKeyPair != null) {
                            contextBuilder.keyManager(tlsKeyPair.privateKey(), tlsKeyPair.certificateChain());
                        }
                        if (!trustedCerts.isEmpty()) {
                            contextBuilder.trustManager(trustedCerts);
                        }
                        applyTlsConfig(contextBuilder);
                        return contextBuilder;
                    },
                    forceHttp1, engineType, allowsUnsafeCiphers, null, null);
        }
    }
Returns an {@link SslContext} for the specified {@link SslContextMode} and {@link TlsKeyPair}.
Note that the returned {@link SslContext} should be released via
{@link ReferenceCountUtil#release(Object)} when it is no longer used.
core/src/main/java/com/linecorp/armeria/internal/common/SslContextFactory.java