【问题标题】:HTTPS- CertificateHTTPS-证书
【发布时间】:2014-09-29 07:58:52
【问题描述】:

我使用以下命令创建了密钥

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

在我使用骆驼端点暴露 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 访问时,它显示为无效证书。请告诉我这个问题的原因并给出解决方案。

【问题讨论】:

    标签: https


    【解决方案1】:

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

    使用CA证书What are CA Certificates时不会出现警告

    您可以通过将证书添加到受信任的根 CA 存储 Example 来抑制警告

    【讨论】:

    • 谢谢@Karikalan
    【解决方案2】:

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

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

    这是CA 的维基。

    【讨论】:

    • 您的回答“几乎正确”。如果在 Java Web 服务器前面有 Apache,它就可以工作。以下是使用 Let's Encrypt 颁发的证书的 Java 特定说明的链接:vaadin.com/blog/-/blogs/…
    • 是的,我只是假设你和我一样使用apache,谢谢你关于java服务器ca的博客链接
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-10-18
    • 2021-09-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多