static SSLSession validateSslContext(SslContext sslContext, TlsEngineType tlsEngineType) {
        if (!sslContext.isServer()) {
            throw new IllegalArgumentException("sslContext: " + sslContext + " (expected: server context)");
        }

        SSLEngine serverEngine = null;
        SSLEngine clientEngine = null;
        final SSLSession sslSession;

        try {
            serverEngine = sslContext.newEngine(ByteBufAllocator.DEFAULT);
            serverEngine.setUseClientMode(false);
            serverEngine.setNeedClientAuth(false);

            // Create a client-side engine with very permissive settings.
            final SslContext sslContextClient =
                    buildSslContext(() -> SslContextBuilder.forClient()
                                                           .trustManager(InsecureTrustManagerFactory.INSTANCE),
                                    tlsEngineType, true, null);
            clientEngine = sslContextClient.newEngine(ByteBufAllocator.DEFAULT);
            clientEngine.setUseClientMode(true);
            clientEngine.setEnabledProtocols(clientEngine.getSupportedProtocols());
            clientEngine.setEnabledCipherSuites(clientEngine.getSupportedCipherSuites());

            final ByteBuffer packetBuf = ByteBuffer.allocate(clientEngine.getSession().getPacketBufferSize());

            // Wrap an empty app buffer to initiate handshake.
            wrap(clientEngine, packetBuf);

            // Feed the handshake packet to the server engine.
            packetBuf.flip();
            unwrap(serverEngine, packetBuf);

            // See if the server has something to say.
            packetBuf.clear();
            wrap(serverEngine, packetBuf);

            sslSession = serverEngine.getHandshakeSession();
        } catch (SSLException e) {
            throw new IllegalStateException("failed to validate SSL/TLS configuration: " + e.getMessage(), e);
        } finally {
            ReferenceCountUtil.release(serverEngine);
            ReferenceCountUtil.release(clientEngine);
        }

        return sslSession;
    }
Makes sure the specified {@link SslContext} is configured properly. If configured as client context or
key store password is not given to key store when {@link SslContext} was created using
{@link KeyManagerFactory}, the validation will fail and an {@link IllegalStateException} will be raised.
core/src/main/java/com/linecorp/armeria/server/ServerSslContextUtil.java