apache ssl - 无法获得本地颁发者证书

Dio*_*ius 11 openssl certificate-authority apache-2.4

不知何故,今天突然我的 Seafile 客户端抛出了这个错误。我不相信这是一个 seafile 问题,因为我的 openssl 抛出了完全相同的错误:

user@nb-user:~$ echo |openssl s_client -connect seafile.mydomain.ch:443
CONNECTED(00000003)
depth=1 C = IL, O = StartCom Ltd., OU = Secure Digital Certificate Signing, CN = StartCom Class 2 Primary Intermediate Server CA
verify error:num=20:unable to get local issuer certificate
verify return:0
---
Certificate chain
 0 s:/description=5RygJ9fx8e2SBLzw/C=CH/ST=Thurgau/L=Frauenfeld/O=mydomain GmbH/CN=*.mydomain.ch/emailAddress=postmaster@mydomain.ch
   i:/C=IL/O=StartCom Ltd./OU=Secure Digital Certificate Signing/CN=StartCom Class 2 Primary Intermediate Server CA
 1 s:/C=IL/O=StartCom Ltd./OU=Secure Digital Certificate Signing/CN=StartCom Class 2 Primary Intermediate Server CA
   i:/C=IL/O=StartCom Ltd./OU=Secure Digital Certificate Signing/CN=StartCom Certification Authority
---
Server certificate
-----BEGIN CERTIFICATE-----
MIIGqzCCBZOgAwIBAgIDAjmGMA0GCSqGSIb3DQEBBQUAMIGMMQswCQYDVQQGEwJJ
TDEWMBQGA1UEChMNU3RhcnRDb20gTHRkLjErMCkGA1UECxMiU2VjdXJlIERpZ2l0
[... some more lines]
-----END CERTIFICATE-----
subject=/description=5RygJ9fx8e2SBLzw/C=CH/ST=Thurgau/L=Frauenfeld/O=mydomain GmbH/CN=*.mydomain.ch/emailAddress=postmaster@mydomain.ch
issuer=/C=IL/O=StartCom Ltd./OU=Secure Digital Certificate Signing/CN=StartCom Class 2 Primary Intermediate Server CA
---
No client certificate CA names sent
---
SSL handshake has read 3997 bytes and written 431 bytes
---
New, TLSv1/SSLv3, Cipher is ECDHE-RSA-AES256-GCM-SHA384
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
SSL-Session:
    Protocol  : TLSv1.2
    Cipher    : ECDHE-RSA-AES256-GCM-SHA384
    Session-ID: 96E1F6B9E123F8F8C1C1E8FB0DBACDBBE76ECB3E2CF5C46C1FD2CF46833C8212
    Session-ID-ctx: 
    Master-Key: 25837E1786B0CC60E676D0694319641CD0887F9CAF48A820F1C0D6ABA6FDE0742551816ACD2A4885B0D3FC143716B1F6
    Key-Arg   : None
    PSK identity: None
    PSK identity hint: None
    SRP username: None
    TLS session ticket lifetime hint: 300 (seconds)
    TLS session ticket:
    0000 - 88 15 c0 c5 30 04 63 d6-ff 7c 72 c4 12 84 7b d6   ....0.c..|r...{.
    0010 - 73 33 8d 91 7c da ce 22-23 d0 31 fb c1 7f 1c 9c   s3..|.."#.1.....
    [... some more lines]

    Start Time: 1424953937
    Timeout   : 300 (sec)
    Verify return code: 20 (unable to get local issuer certificate)
---
DONE
Run Code Online (Sandbox Code Playgroud)

对我来说,链条部分看起来正是它应该的样子。apache conf 也应该没问题:

root@i-can-haz-data ~ # cat /etc/apache2/sites-enabled/seafile.conf

<VirtualHost *:443>

    ServerName seafile.mydomain.ch
    DocumentRoot /opt/seafile/www

    [... seafile specific things]

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    SSLEngine on
    SSLCertificateFile      /etc/ssl/custom/wildcardmydomain.ch.crt
    SSLCertificateKeyFile   /etc/ssl/custom/wildcardmydomain.ch.key
    SSLCertificateChainFile /etc/ssl/custom/wildcardmydomain.ch.chain.crt

    [... seafile specific things]

</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

我找不到我的问题是什么......(ca-certificates 安装在我的 lubuntu 14.04 上)。他们的网站不适用,因为他们链接了他们的 1 类证书,但我的网站是由他们的 2 类证书颁发的。

seb*_*bix 20

verify error:num=20:unable to get local issuer certificate
Run Code Online (Sandbox Code Playgroud)

OpenSSL 的此错误意味着程序无法验证证书的颁发者或所提供链的最顶层证书。在某些情况下可能会发生这种情况,例如:

  • 证书的证书链不是由另一方提供的,或者它没有(它是自签名的)。
  • 根证书不在受信任根证书的本地数据库中。
  • 未提供受信任根证书的本地数据库,因此 OpenSSL 不会查询。要明确提供证书的路径,请使用-CApath-CAfile选项。对于 Debian 和 Ubuntu,例如:

    -CApath /etc/ssl/certs/
    -CAfile /etc/ssl/certs/ca-certificates.crt
    
    Run Code Online (Sandbox Code Playgroud)

    从而导致

    openssl s_client -connect example.com:443 -CApath /etc/ssl/certs/
    openssl s_client -connect example.com:443 -CAfile /etc/ssl/certs/ca-certificates.crt
    
    Run Code Online (Sandbox Code Playgroud)

后者需要更多信息。自 2009 年以来,Ubuntu 中有一个OpenSSL公开错误报告

使用 -CApath 似乎将 -CAfile 设置为 /etc/ssl/certs/ca-certificates.crt 的默认值。

不管你给出的 path by 是什么-CApath,它都可以工作,因为-CAfile也被设置为它的默认值(之前是空的)。因此,不要依赖 OpenSSL 的默认行为来通过本地证书数据库验证证书,这可能是假的!