HTTPS-证书

时间:2014-09-29 07:58:53

标签: https

enter image description here

我使用以下命令

创建了密钥

keytool -genkey -keyalg RSA -alias selfsigned -keystore keystore.jks -storepass password -validity 360 -keysize 2048

在我使用驼峰端点暴露HTTPS连接之后

public class 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 个答案:

答案 0 :(得分:1)

这是一个警告,因为您使用的自签名证书不会被浏览器信任。

使用CA证书What are CA Certificates

时,不会发出警告

您可以通过将证书添加到受信任的根CA存储区Example

来取消警告

答案 1 :(得分:1)

浏览器无法识别自签名证书。只能识别CA签名证书。

您可以使用Let的加密项目设置免费的可信证书,这是how-to tutorial

这是CA的维基。