简体   繁体   English

根据客户提供不同的SSL证书

[英]Different ssl-certs delivered depending on client

I'm using a free SSL-cert from startssl.com for my Artifactory-repo. 我为Artifactory-repo使用了startssl.com提供的免费SSL证书。 It's all green and nice in my browsers, but of course not from Java. 在我的浏览器中,这一切都是绿色的,但是当然不是Java的。 So I installed the cacerts with this handy script: 所以我用这个方便的脚本安装了cacerts:

http://www.ailis.de/~k/uploads/scripts/import-startssl http://www.ailis.de/~k/uploads/scripts/import-startssl

But I STILL get the: 但是我仍然得到:

Server access Error: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException

error. 错误。 JAVA_HOME set correctly. JAVA_HOME设置正确。 Any suggestion highly appreciated! 任何建议高度赞赏!

More info: 更多信息:

Its Ivy from SBT 0.12.2 (using pualp's script https://github.com/paulp/sbt-extras ) that is barfing on the cert: 它来自SBT 0.12.2的常春藤(使用pualp的脚本https://github.com/paulp/sbt-extras )正在对证书进行反驳:

[info] Resolving net.liftmodules#omniauth_2.10;2.5-SNAPSHOT-0.7-SNAPSHOT ...
[error] Server access Error: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target url=https://repo.woodenstake.se/all/net/liftmodules/omniauth_2.10/2.5-SNAPSHOT-0.7-SNAPSHOT/maven-metadata.xml

-- Update: -更新:

The problem seems to be something totally different not related to Java per se. 问题似乎是与Java本身完全无关的东西。 Visiting the page from a browser yields a green cert and I can see the info that its signed from StartSSL. 从浏览器访问页面会产生绿色证书,我可以看到它从StartSSL签名的信息。 But even wget or curl chokes and tells me that this is a self-signed cert. 但是,即使是wget或curl扼流圈,也告诉我这是一个自签名证书。 It seems that different certs are delivered depending on the client. 似乎根据客户提供了不同的证书。

The repo is at https://repo.woodenstake.se/ - If you paste this in your browser I would guess that you get the StartSSL-cert. 仓库位于https://repo.woodenstake.se/-如果将其粘贴到浏览器中,我猜您会获得StartSSL证书。 BUT if you do wget https://repo.woodenstake.se/ you get some old self-signed cert that I don't know where it comes from. 但是,如果您确实知道https://repo.woodenstake.se/,则会得到一些旧的自签名证书,但我不知道它来自何处。

-- Update to update: -更新更新:

So the problem is that I'm serving a few sites of the form *.woodenstake.se. 因此,问题在于我正在为* .woodenstake.se形式的几个网站提供服务。 I got the feeling that it would be possible to have different certs like: 我感到有可能拥有不同的证书,例如:

server {
    listen 443;
    server_name site1.woodenstake.se;
    client_max_body_size 512m;
    ssl on;
    ssl_certificate cert1.crt;
    ssl_certificate_key cert1.key;
    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        if (!-f $request_filename) {
            proxy_pass http://server1;
            break;
        }
    }
}

server {
    listen 443;
    server_name site2.woodenstake.se;
    client_max_body_size 512m;
    ssl on;
    ssl_certificate cert2.crt;
    ssl_certificate_key cert2.key;
    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        if (!-f $request_filename) {
            proxy_pass http://server2;
            break;
        }
    }
}

and it works just fine in all my browsers. 而且在我所有的浏览器中都可以正常工作。

However, it doesn't work from wget or JDK6. 但是,在wget或JDK6中不起作用。

Problem was something completely different. 问题是完全不同的。 Apparently you can't have more than one certificate on the same IP and be sure that all clients can handle it. 显然,在同一IP上您不能拥有多个证书,并确保所有客户端都可以处理该证书。 I have a few tools on this machine and my nginx-config had references to both the StartSSL cert for this site but also to a self-signed (snakeoil) cert for some other sites. 我在这台机器上有一些工具,我的nginx-config既引用了该站点的StartSSL证书,也引用了一些其他站点的自签名(snakeoil)证书。

My nginx supports TLS SNI: 我的Nginx支持TLS SNI:

~ $ sudo nginx -V
nginx version: nginx/0.7.65
TLS SNI support enabled

but apparently wget and Java clients doesn't handle it. 但是显然wget和Java客户端无法处理它。 All my browsers do though. 我所有的浏览器都可以。

Maybe it's possible to do something like: 也许可以做类似的事情:

http://library.linode.com/security/ssl-certificates/subject-alternate-names http://library.linode.com/security/ssl-certificates/subject-alternate-names

but I don't know if it is possible to get StartSSL to sign it. 但我不知道是否可以通过StartSSL对其进行签名。

More info here: 更多信息在这里:

http://www.carloscastillo.com.ar/2011/05/multiple-ssl-certificates-on-same-ip.html http://www.carloscastillo.com.ar/2011/05/multiple-ssl-certificates-on-same-ip.html

Wget test on my Ubuntu-desktop: 在我的Ubuntu桌面上进行Wget测试:

viktor@hedefalk-i7:~$ wget https://bob.sni.velox.ch/
--2013-03-25 17:07:19--  https://bob.sni.velox.ch/
Resolving bob.sni.velox.ch (bob.sni.velox.ch)... 62.75.148.60
Connecting to bob.sni.velox.ch (bob.sni.velox.ch)|62.75.148.60|:443... connected.
ERROR: no certificate subject alternative name matches
    requested host name `bob.sni.velox.ch'.
To connect to bob.sni.velox.ch insecurely, use `--no-check-certificate'

So I think the answer to my question is 所以我认为我的问题的答案是

Your version of Java (or all, but maybe it works in JDK7: http://docs.oracle.com/javase/7/docs/technotes/guides/security/enhancements-7.html ) doesn't support TLS SNI so nginx can't be sure which certificate to serve since this is negotiated before http. 您的Java版本(或全部版本,但也许可以在JDK7中使用: http : //docs.oracle.com/javase/7/docs/technotes/guides/security/enhancements-7.html )不支持TLS SNI,因此nginx无法确定要提供哪个证书,因为该证书是在http之前协商确定的。 Buy a wildcard-cert for real money from the man or cry a river. 从该男子那里购买真钱通配符证书或哭泣。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM