Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/394.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无密钥库的restlessl_Java_Ssl_Restlet_Restlet 2.3.1 - Fatal编程技术网

Java 无密钥库的restlessl

Java 无密钥库的restlessl,java,ssl,restlet,restlet-2.3.1,Java,Ssl,Restlet,Restlet 2.3.1,Restlet是否可以在没有密钥库的情况下使用SSL证书?我的应用程序当前使用的DefaultSslContextFactory如下所示 ... int httpPort = appConfig.getHttpPort(); int httpsPort = appConfig.getHttpsPort(); Component c = new Component(); c.getDefaultHost().attach(ROOT_PATH, new We

Restlet是否可以在没有密钥库的情况下使用SSL证书?我的应用程序当前使用的
DefaultSslContextFactory
如下所示

    ...
    int httpPort = appConfig.getHttpPort();
    int httpsPort = appConfig.getHttpsPort();

    Component c = new Component();
    c.getDefaultHost().attach(ROOT_PATH, new WebApiApplication());

    if (new KeyStoreManager().defaultJksContainsAlias("tls")) {

        char[] secret = appConfig.getJksSecret().toCharArray();
        String keystore = appConfig.getJksKeystore();

        // Increase the ports until we find a suitable one
        while (occupied(httpsPort)) {
            httpsPort++;
        }
        Server https = new Server(c.getContext().createChildContext(), Protocol.HTTPS, httpsPort, c);
        System.out.println("Starting HTTPS services on port " + httpsPort + "...");

        DefaultSslContextFactory sslContextFactory = new DefaultSslContextFactory();
        sslContextFactory.setProtocol("SSL");
        sslContextFactory.setKeyStorePath(keystore);
        sslContextFactory.setKeyStorePassword(secret);
        sslContextFactory.setKeyStoreKeyPassword(secret);
        sslContextFactory.setKeyStoreType("JKS");
        https.getContext().getAttributes().put("sslContextFactory", sslContextFactory);
        c.getServers().add(https);
    } else {
        System.out.println("No TLS certificates detected. Skipping HTTPS services...");
    }

    // Increate the ports until we find a suitable one
    while (occupied(httpPort)) {
        httpPort++;
    }
    System.out.println("Starting HTTP services on port " + httpPort + "...");

    Server http = new Server(Protocol.HTTP, httpPort, c);
    c.getServers().add(http);
    try {
        c.start();
    } catch (Exception e) {
        LOG.error("Failed to start core component", e);
        System.exit(-1);
    }
    ...

问题是Java密钥库在导入现有证书时不是很友好!理想情况下,我只想指定路径
.key
.crt
,方法与我为nginx指定路径的方法相同

你有没有找到解决这个问题的办法,我也面临着类似的问题?没有,很遗憾,我没有找到直接的解决办法。但是,我确实间接地解决了这个问题,将使用纯http的服务器放在负载平衡器后面,并执行https->http转发。