我使用下面的命令创建了密钥
keytool -genkey -keyalg RSA -alias selfsigned -keystore keystore.jks -storepass password -validity 360 -keysize 2048
在我使用camel endpoints 暴露HTTPS连接之后
公共类HTTPSCamelEndPoint {
public Endpoint httpsConfig(CamelContext context) throws Exception
{
KeyStoreParameters ksp = new KeyStoreParameters();
ksp.setResource("C:\\Users\\sithamparamd\\keystore.jks");
ksp.setPassword("123456");
KeyManagersParameters kmp = new KeyManagersParameters();
kmp.setKeyStore(ksp);
kmp.setKeyPassword("password");
SSLContextParameters scp = new SSLContextParameters();
scp.setKeyManagers(kmp);
JettyHttpComponent jettyComponent =context.getComponent("jetty", JettyHttpComponent.class);
jettyComponent.setSslContextParameters(scp);
//jettyComponent.createEndpoint("jetty:https://192.168.16.98:4443/myservice");
return jettyComponent.createEndpoint("jetty:https://192.168.16.98:4443/myservice");
}
public static void main(String[] args) throws Exception {
HTTPSCamelEndPoint httpsCamelEndPoint= new HTTPSCamelEndPoint();
CamelContext camelContext=httpsCamelEndPoint.getContext();
final Endpoint endpoint=httpsCamelEndPoint.httpsConfig(camelContext);
System.out.println(endpoint);
camelContext.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
// TODO Auto-generated method stub
from(endpoint).process(new Processor() {
public void process(Exchange arg0) throws Exception {
// TODO Auto-generated method stub
System.out.println("GOT THE MSG !!!!");
}
});
}
});
camelContext.start();
}
public CamelContext getContext()
{
CamelContext camelContext=new DefaultCamelContext();
JettyHttpComponent httpComponent=new JettyHttpComponent();
camelContext.addComponent("jetty", httpComponent);
return camelContext;
}
}
但是,当我通过URL访问它显示为无效证书 . 请告诉我这个原因并给出解决方案 .
2 回答
这是一个警告,因为您使用的是自签名证书,您生成的证书不受浏览器信任 .
使用CA证书时不会发出警告What are CA Certificates
您可以通过将证书添加到受信任的根CA存储来禁止警告Example
浏览器无法识别自签名证书 . 只能识别CA签名证书 .
您可以使用Let的加密项目设置免费的可信证书,这是how-to tutorial .
这是CA的维基 .