Java 无密钥库的restlessl
Restlet是否可以在没有密钥库的情况下使用SSL证书?我的应用程序当前使用的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
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转发。