コメントで言っていたように、以前の質問の 1 つに対する回答で、これを行うには a を使用する必要がありますKeyManager
。
これにはさまざまな方法があります。jSSLutilsは、もう少し便利にするライブラリです (ただし、手動で行うこともできます)。FixedServerAliasKeyManagerの例があります。それを行う最短の方法の 1 つは、次のようなものを使用することです。
X509SSLContextFactory sslContextFactory = new X509SSLContextFactory();
// By default, this would use the keystore passed with the usual system properties.
sslContextFactory.setKeyManagerWrapper(
new FixedServerAliasKeyManager.Wrapper("the-alias-you-want"));
// You could read the alias name from a custom system property, for example.
SSLContext sslContext = sslContextFactory.buildSSLContext("TLS");
SSLServerSocketFactory sslServerSocketFactory = sslContext.getServerSocketFactory();