【问题标题】:Error Loading extension section usr_cert加载扩展部分 usr_cert 时出错
【发布时间】:2014-08-06 22:59:13
【问题描述】:

我在 Ubuntu 14.04 机器上运行 openvpn。在 OpenSSL 升级之前设置很好,然后当我尝试使用 easy-rsa 创建新的客户端证书时,我收到了以下消息:

root@:easy-rsa# ./pkitool onokun
Using Common Name: onokun
Generating a 2048 bit RSA private key
.+++
........+++
writing new private key to 'onokun.key'
-----
Using configuration from /etc/openvpn/easy-rsa/openssl-1.0.0.cnf
Error Loading extension section usr_cert
3074119356:error:0E06D06C:configuration file routines:NCONF_get_string:no value:conf_lib.c:335:group=CA_default name=email_in_dn
3074119356:error:2207507C:X509 V3 routines:v2i_GENERAL_NAME_ex:missing value:v3_alt.c:537:
3074119356:error:22098080:X509 V3 routines:X509V3_EXT_nconf:error in extension:v3_conf.c:93:name=subjectAltName, value=onokun

此问题与报告的错误不同,即which opensslcnf 脚本找不到要使用的openssl.cnf 的匹配版本(上面的消息显示openssl-1.0.0.cnf)。我执行了 Google 搜索,但没有找到答案。

以下是一些环境信息:

## openvpn
OpenVPN 2.3.2 i686-pc-linux-gnu [SSL (OpenSSL)] [LZO] [EPOLL] [PKCS11] [eurephia] [MH] [IPv6] built on Feb  4 2014
Originally developed by James Yonan

## openssl
OpenSSL 1.0.1f 6 Jan 2014

## dpkg --get-selections | grep ssl
libgnutls-openssl27:i386                        install
libio-socket-ssl-perl                           install
libnet-smtp-ssl-perl                            install
libnet-ssleay-perl                              install
libssl-dev:i386                                 install
libssl-doc                                      install
libssl0.9.8:i386                                install
libssl1.0.0:i386                                install
openssl                                         install
ssl-cert                                        install

我应该看什么来解决这个问题?谢谢,

【问题讨论】:

    标签: ssl openssl openvpn


    【解决方案1】:
    Using configuration from /etc/openvpn/easy-rsa/openssl-1.0.0.cnf
    Error Loading extension section usr_cert
    

    我没有/etc/openvpn/easy-rsa/openssl-1.0.0.cnf,所以请谨慎对待...

    opensslconf.h 来自 OpenSSL 的分发版是否包含该部分:

    openssl-1.0.1h$ grep -R usr_cert *
    apps/openssl-vms.cnf:x509_extensions    = usr_cert      # The extensions to add to the cert
    apps/openssl-vms.cnf:[ usr_cert ]
    apps/openssl.cnf:x509_extensions    = usr_cert      # The extensions to add to the cert
    apps/openssl.cnf:[ usr_cert ]
    

    你能恢复旧版本的/etc/openvpn/easy-rsa/openssl-1.0.0.cnf吗?

    这是来自apps/openssl.cnf 的部分。如果它丢失,您可以考虑将其添加到 Easy RSA 的配置文件中。首先,尝试一个空白部分。然后尝试将原始代码添加回来。

    [ usr_cert ]
    
    # These extensions are added when 'ca' signs a request.
    
    # This goes against PKIX guidelines but some CAs do it and some software
    # requires this to avoid interpreting an end user certificate as a CA.
    
    basicConstraints=CA:FALSE
    
    # Here are some examples of the usage of nsCertType. If it is omitted
    # the certificate can be used for anything *except* object signing.
    
    # This is OK for an SSL server.
    # nsCertType            = server
    
    # For an object signing certificate this would be used.
    # nsCertType = objsign
    
    # For normal client use this is typical
    # nsCertType = client, email
    
    # and for everything including object signing:
    # nsCertType = client, email, objsign
    
    # This is typical in keyUsage for a client certificate.
    # keyUsage = nonRepudiation, digitalSignature, keyEncipherment
    
    # This will be displayed in Netscape's comment listbox.
    nsComment           = "OpenSSL Generated Certificate"
    
    # PKIX recommendations harmless if included in all certificates.
    subjectKeyIdentifier=hash
    authorityKeyIdentifier=keyid,issuer
    
    # This stuff is for subjectAltName and issuerAltname.
    # Import the email address.
    # subjectAltName=email:copy
    # An alternative to produce certificates that aren't
    # deprecated according to PKIX.
    # subjectAltName=email:move
    
    # Copy subject details
    # issuerAltName=issuer:copy
    
    #nsCaRevocationUrl      = http://www.domain.dom/ca-crl.pem
    #nsBaseUrl
    #nsRevocationUrl
    #nsRenewalUrl
    #nsCaPolicyUrl
    #nsSslServerName
    
    # This is required for TSA certificates.
    # extendedKeyUsage = critical,timeStamping
    

    【讨论】:

    • 谢谢,我从你那里复制了 usr_cert 部分,一切正常。我的 openssl-1.0.0.cnf 来自全新安装的版本:2.2.2-1 (Ubuntu 14.04),作为记录,我在这里区分了它们 pastebin.com/gCwZX2Z0 并仍在试图找出问题所在。跨度>
    【解决方案2】:

    通过比较没有此问题的早期 Ubuntu 14.04 安装,似乎特定问题与“subjectAltName”有关。我没有详细了解它的作用,但下面的命令将修复您的“openssl-1.0.0.cnf”文件:

    perl -p -i -e 's|^(subjectAltName=)|#$1|;' /etc/openvpn/easy-rsa/openssl-1.0.0.cnf
    

    我可能应该提交一份错误报告。

    【讨论】:

    • 这似乎破坏了文件,我收到此错误:/usr/share/easy-rsa/openssl-1.0.0.cnf 的第 222 行错误
    • 我评论了`/usr/share/easy-rsa/openssl-1.0.0.cnf`中的“subjectAltName=”行,而不是运行这个单行。一切顺利。
    • 遇到同样的问题,正在使用本指南,这解决了问题(步骤 7)digitalocean.com/community/tutorials/…
    【解决方案3】:

    我终于得到了他的工作(在我的机器上) 首先我的设置有点不同,我在 Windows10 上,运行 OpenSSL 1.0.2h。我正在尝试为测试生成多个证书、CA 和其他内容,但出现错误:

    configuration file routines:NCONF_get_string:no value:.\crypto\conf\conf_lib.c:324:group=CA_default name=email_in_dn

    为了解决这个问题,我发现将条目 email_in_dn = no 放在 CA_Default openssl.cfg 部分中,如下所示

    ####################################################################
    [ CA_default ]
    dir     = ./demoCA              # Where everything is kept
    certs       = $dir/certs        # Where the issued certs are kept
    crl_dir     = $dir/crl          # Where the issued crl are kept
    database    = $dir/index.txt    # database index file.
    new_certs_dir   = $dir/newcerts # default place for new certs.
    
    certificate = $dir/ca.crt       # The CA certificate
    serial      = $dir/serial       # The current serial number
    crl     = $dir/crl.pem          # The current CRL
    private_key = $dir/private/caprivkey.pem# The private key
    RANDFILE    = $dir/private/.rand    # private random number file
    x509_extensions = usr_cert      # The extentions to add to the cert
    email_in_dn = no                # <-- fixes CONF_get_string:no value
    

    我希望这对其他人有帮助。

    【讨论】:

      【解决方案4】:

      这是作为 Ubuntu 中的错误提交的。见SSL certificate creation crashes without subjectAltName

      Yuriy 描述的解决方法似乎有效(从启动板复制):

      在 /usr/share/easy-rsa/pkitool 文件中

      只需替换表达式:

      KEY_ALTNAMES="$KEY_CN"

      到:

      KEY_ALTNAMES="DNS:${KEY_CN}"

      在我的文件版本中,这是第 284 行,就在字符串“Using Common Name”之后

      【讨论】:

        【解决方案5】:

        要摆脱这个错误:

        3074119356:error:0E06D06C:configuration file routines:NCONF_get_string:no value:conf_lib.c:335:group=CA_default name=email_in_dn
        

        使用

        -noemailDN 
        

        在 openssl 命令中。

        例如:

        $  openssl ca -batch -config openssl.cnf -extensions usr_cert -noemailDN -days 375 -notext -md sha256 -in csr/www.example8.com.csr.pem -out certs/www.example8.com.cert.pem -verbose -passin pass:changeit
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2017-10-10
          • 1970-01-01
          • 2017-10-02
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2017-09-20
          相关资源
          最近更新 更多