Java-独立SSL Web服务-JAX-WS,JRE,无Web服务器

Java-独立SSL Web服务-JAX-WS,JRE,无Web服务器,java,ssl,web,jks,wsgen,Java,Ssl,Web,Jks,Wsgen,我使用wsgen开发了一个简单的Web服务,它在http(非SSL)下运行良好。我现在需要让它在https(SSL)下工作。我按照找到的密码。所以SSL进程现在正在运行……我正在Eclipse中作为Java应用程序运行。但是,当我尝试访问它时,我得到“安全连接失败”-“无法显示您尝试查看的页面,因为无法验证接收数据的真实性” 也就是说,我是SSL的中间人,所以我可能在这里做错了什么。我使用密钥库资源管理器工具执行了以下操作: -创建了一个新的JKS密钥库。 -生成一个新的密钥对 -将密钥对导出为

我使用wsgen开发了一个简单的Web服务,它在http(非SSL)下运行良好。我现在需要让它在https(SSL)下工作。我按照找到的密码。所以SSL进程现在正在运行……我正在Eclipse中作为Java应用程序运行。但是,当我尝试访问它时,我得到“安全连接失败”-“无法显示您尝试查看的页面,因为无法验证接收数据的真实性”

也就是说,我是SSL的中间人,所以我可能在这里做错了什么。我使用密钥库资源管理器工具执行了以下操作: -创建了一个新的JKS密钥库。 -生成一个新的密钥对 -将密钥对导出为*.pk12文件。 -打开我的浏览器并导入*.pk12。我尝试了*.cer,但浏览器不接受未签名的证书

因此*.jks是直接在Java代码中打开的,这是可行的,我在Eclipse中通过调试进行了验证。SSL服务启动正常,但我仍然在浏览器中遇到相同的错误…另一个困难是我似乎无法找到任何带有任何类型异常/错误的日志文件,甚至无法开始跟踪问题。我不认为这是一个Java问题……我认为这是一个SSL问题,但我不知道从哪里开始

任何帮助都将不胜感激

public static void main(String[] args) throws Exception {
    Endpoint endpoint = Endpoint.create(new RapidCommandService());
    SSLContext ssl =  SSLContext.getInstance("SSLv3");

    KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); 
    KeyStore store = KeyStore.getInstance(KeyStore.getDefaultType());

    getLog().debug ( SHORT_NAME + ".main() - Java User Directory..........................[" + System.getProperty ( "user.dir" ) + "]" );
    getLog().debug ( SHORT_NAME + ".main() - Java Home Directory..........................[" + System.getProperty ( "java.home" ) + "]" );
    getLog().debug ( SHORT_NAME + ".main() - Java Version.................................[" + System.getProperty ( "java.version" ) + "]" );

    //Load the JKS file (located, in this case, at D:\keystore.jks, with password 'test'
    store.load(new FileInputStream("C:\\usr\\apps\\java\\jre-170-65\\lib\\security\\rapid-command-service.jks"), "changeit".toCharArray()); 

    //init the key store, along with the password 'test'
    kmf.init(store, "changeit".toCharArray());
    KeyManager[] keyManagers = new KeyManager[1];
    keyManagers = kmf.getKeyManagers();

    //Init the trust manager factory
    TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());

    //It will reference the same key store as the key managers
    tmf.init(store);

    TrustManager[] trustManagers = tmf.getTrustManagers();

    ssl.init(keyManagers, trustManagers, new SecureRandom());
    getLog().debug ( SHORT_NAME + ".main() - Java SSL Truststore..........................[" + System.getProperty ( "javax.net.ssl.trustStore" ) + "]" );
    getLog().debug ( SHORT_NAME + ".main() - Java SSL Keystore............................[" + System.getProperty ( "javax.net.ssl.keyStore" ) + "]" );

    //Init a configuration with our SSL context
    HttpsConfigurator configurator = new HttpsConfigurator(ssl);
    System.setProperty("javax.net.debug", "ssl");

    //Create a server on localhost, port 443 (https port)
    HttpsServer httpsServer = HttpsServer.create(new InetSocketAddress("localhost", 443), 443);
    httpsServer.setHttpsConfigurator(configurator);


    //Create a context so our service will be available under this context
    HttpContext context = httpsServer.createContext("/rapidCommandService");
    httpsServer.start();

    //Finally, use the created context to publish the service
    endpoint.publish(context);

}
试一试

目前已知SSLv3易受攻击,您的浏览器可能不会接受这样配置的服务器


另一个选项使用
-k
选项尝试
curl
连接到服务器。

您使用什么浏览器和版本访问该服务?很可能,在没有更多受支持的SSL版本之前,浏览器不会接受服务器的证书。是的,浏览器:Firefox,版本:39.0,JRE 1.6。Firefox证书管理器中似乎有5个选项卡:您的证书、人员、服务器、权限和其他。我将我的pk12添加到您的证书中,但它没有任何作用。似乎有效…Firefox提示我出现异常,但它允许我接受风险并添加异常并继续。很好。此风险消息是由于您正在使用的自签名证书造成的。
SSLContext ssl =  SSLContext.getInstance("TLSv1.2");