Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You won't be able to use the default <code>SSLServerSocketFactory</code>.</p> <p>Instead, <a href="http://java.sun.com/javase/6/docs/api/javax/net/ssl/SSLContext.html#init(javax.net.ssl.KeyManager[],%20javax.net.ssl.TrustManager[],%20java.security.SecureRandom)" rel="nofollow noreferrer">initialize</a> a different <code>SSLContext</code> for each site, each using a <code>KeyManagerFactory</code> <a href="http://java.sun.com/javase/6/docs/api/javax/net/ssl/KeyManagerFactory.html#init(java.security.KeyStore,%20char[])" rel="nofollow noreferrer">configured</a> with a key store containing a key entry with correct server certificate. (After initializing the <code>KeyManagerFactory</code>, pass its <a href="http://java.sun.com/javase/6/docs/api/javax/net/ssl/KeyManagerFactory.html#getKeyManagers()" rel="nofollow noreferrer">key managers</a> to the <code>init</code> method of the <code>SSLContext</code>.)</p> <p>After the <code>SSLContext</code> is initalized, <a href="http://java.sun.com/javase/6/docs/api/javax/net/ssl/SSLContext.html#getServerSocketFactory()" rel="nofollow noreferrer">get its <code>SSLServerSocketFactory</code></a>, and use that to create your listener.</p> <pre><code>KeyStore identity = KeyStore.getInstance(KeyStore.getDefaultType()); /* Load the keystore (a different one for each site). */ ... SSLContext ctx = SSLContext.getInstance("TLS"); KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); kmf.init(identity, password); ctx.init(kmf.getKeyManagers(), null, null); SSLServerSocketFactory factory = ctx.getServerSocketFactory(); ServerSocket server = factory.createSocket(port); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload