2017-05-06 47 views

回答

0

明白了:

ListenerFactory factory = new ListenerFactory(); 
    SslConfigurationFactory ssl = new SslConfigurationFactory(); 
    ssl.setClientAuthentication("true"); 
    ssl.setTruststoreFile(new File("trust.jks")); 
    ssl.setTruststorePassword("trust-password"); 
    ssl.setKeystoreFile(new File("certs.jks")); 
    ssl.setKeystorePassword("certs-password"); 
    factory.setSslConfiguration(ssl.createSslConfiguration()); 
    factory.setImplicitSsl(true); 

服务器将强制用户使用证书进行连接,并只接受那些包含在trust.jks。