【问题标题】:OpenSSL and apache2 wildcard self-signed certificate for nested subdomain嵌套子域的 OpenSSL 和 apache2 通配符自签名证书
【发布时间】:2012-01-20 05:10:21
【问题描述】:

我对嵌套子域和通配符 openssl 证书有一些问题。也许这是因为子域类型是:site1.parisgeo.cnrs.fr,或 site2.parisgeo.cnrs.fr,或其他子域,如 xxxx.parisgeo。 cnrs.fr

当我创建自签名证书时,我输入 CN = *.parisgeo.cnrs.fr,但似乎无法在此站点上连接,例如使用此配置的 partage.parisgeo.cnrs.fr!参数。

我的虚拟主机和我的 apache2 conf 工作没有通配符证书,所以我认为问题不在这里:

port.conf

 NameVirtualHost *:443
 Listen 443

我有一个示例虚拟主机:

<VirtualHost *:443>
  ServerName partage.parisgeo.cnrs.fr
  ServerAlias www.partage.parisgeo.cnrs.Fr

  DocumentRoot /var/www/owncloud

        <Directory /var/www/owncloud>
                Options -Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                Allow from all
        </Directory>

   SSLEngine on

   SSLCertificateFile    /etc/ssl/parisgeo.cnrs.fr.crt
   SSLCertificateKeyFile /etc/ssl/parisgeo.cnrs.fr.key
   </VirtualHost>

我这样生成我的证书(CN = *.parisgeo.cnrs.fr):

openssl genrsa -des3 -out ca.key 2048
openssl req -new -x509 -days 3650 -key ca.key -out ca.crt
openssl req -newkey rsa:1024 -nodes -keyout parisgeo.cnrs.fr.key -out parisgeo.cnrs.fr.csr

openssl x509 -req -days 3650 -in parisgeo.cnrs.fr.csr -CA ca.crt -CAcreateserial  -CAkey ca.key -out parisgeo.cnrs.fr.crt

我的生成密钥文件的权利:

-rw-r--r-- 1 root root      1424 14 déc.  11:51 ca.crt
-rw-r--r-- 1 root root      1743 14 déc.  11:50 ca.key
-rw-r--r-- 1 root root        17 14 déc.  12:13 ca.srl
-rw-r--r-- 1 root root       981 14 déc.  12:13 parisgeo.cnrs.fr.crt
-rw-r--r-- 1 root root       627 14 déc.  12:08 parisgeo.cnrs.fr.csr
-rw-r--r-- 1 root root       891 14 déc.  12:08 parisgeo.cnrs.fr.key

当我尝试使用 openssl 连接和测试证书时:

root@xxxx:/etc/ssl# openssl s_client -connect partage.parisgeo.cnrs.fr:443 
CONNECTED(00000003)
depth=0 /C=FR/ST=IDF/L=PARIS/O=CNRS/CN=*.parisgeo.cnrs.fr
verify error:num=18:self signed certificate
verify return:1
depth=0 /C=FR/ST=IDF/L=PARIS/O=CNRS/CN=*.parisgeo.cnrs.fr
verify return:1
---
Certificate chain
 0 s:/C=FR/ST=IDF/L=PARIS/O=CNRS/CN=*.parisgeo.cnrs.fr
   i:/C=FR/ST=IDF/L=PARIS/O=CNRS/CN=*.parisgeo.cnrs.fr
---
Server certificate
-----BEGIN CERTIFICATE-----
..... blabla .....
-----BEGIN CERTIFICATE-----
subject=/C=FR/ST=IDF/L=PARIS/O=CNRS/CN=*.parisgeo.cnrs.fr
issuer=/C=FR/ST=IDF/L=PARIS/O=CNRS/CN=*.parisgeo.cnrs.fr
---
No client certificate CA names sent
---
SSL handshake has read 1253 bytes and written 319 bytes
---
New, TLSv1/SSLv3, Cipher is DHE-RSA-AES256-SHA
Server public key is 1024 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
SSL-Session:
    Protocol  : TLSv1
    Cipher    : DHE-RSA-AES256-SHA
    Session-ID: 7642C70A1E358CAA5901C060A26655DE3AF0BA683C9A598BA7C4B14FF108ADD7
    Session-ID-ctx: 
    Master-Key: 65184165198498498484 6516511321584831181468469431688132138498
    Key-Arg   : None
    Start Time: 1323862629
    Timeout   : 300 (sec)
    Verify return code: 18 (self signed certificate)
---
closed

当我尝试连接到该站点时,firefox 错误是:

An error occurred during a connection to partage.parisgeo.cnrs.fr.
Peer's certificate has an invalid signature.
(Error code: sec_error_bad_signature)

如果您有任何想法可以帮助我解决此问题.. 非常感谢 ! SR。

【问题讨论】:

  • 这个问题解决了吗?我现在坐在同一条船上。

标签: apache certificate openssl subdomain wildcard


【解决方案1】:

我已将说明放入gist

找到您的openssl.conf

  1. 取消注释 req_extensions = v3_req

req_extensions = v3_req # The extensions to add to a certificate request

  1. 将 subjectAltName 添加到 v3_req 部分

[ v3_req ]
basicConstraints = CA:FALSE keyUsage = nonRepudiation, digitalSignature, keyEncipherment subjectAltName = @alt_names

  1. 最后添加您希望此证书对其有效的备用名称。

[alt_names] DNS.1 = yourdomain.com DNS.2 = *.yourdomain.com

运行以下命令:

openssl genrsa -des3 -out hostname.key 2048 openssl rsa -in hostname.key -out hostname-key.pem openssl req -new -key hostname-key.pem -out hostname-request.csr openssl x509 -req -extensions v3_req -days 365 -in hostname-request.csr -signkey hostname-key.pem -out hostname-cert.pem -extfile <path to openssl.conf>

【讨论】:

    猜你喜欢
    • 2017-04-30
    • 2011-07-28
    • 2016-01-22
    • 2012-04-10
    • 2020-10-08
    • 2015-03-06
    • 1970-01-01
    • 2016-09-16
    • 2012-08-24
    相关资源
    最近更新 更多