使用OpenSSL生成具有主体名称的客户端证书

时间:2016-12-13 23:51:24

标签: ssl openssl

我需要使用" NT主要名称生成客户端身份验证证书"和#34; RFC 822名称"在主题备用名称下,与此证书类似,如macOS keychain access(隐藏字段值为AD UPN,如test@domain.com)所示:

example certificate with principal name

我尝试使用OpenSSL使用此命令生成客户端身份验证证书: openssl req -x509 -config cert_config -extensions 'my server exts' -nodes -days 365 -newkey rsa:4096 -keyout client.key -out client.crt

和此cert_config文件:

[ req ]
    prompt             = no
    distinguished_name = my dn

[ my dn ]
            commonName = Test
           countryName = US
          localityName = Anywhere
      organizationName = Test
organizationalUnitName = Dev
   stateOrProvinceName = CO
          emailAddress = info@test.com
                  name = Test Cert
               surname = Cert
             givenName = Test
              initials = TC

[ my server exts ]
      extendedKeyUsage = 1.3.6.1.5.5.7.3.2,1.3.6.1.4.1.311.20.2.2
        subjectAltName = otherName:1.3.18.0.2.4.318;UTF8:test@example.com

但是我无法更正主题替代名称的格式以匹配上图中的示例。我找不到" NT主要名称"的定义。或" RFC 822名称"在OpenSSL documentation下的主题备用名称下。当我在钥匙串访问中查看上面命令生成的证书时,我看到:

produced client certificate

如何指定" NT主要名称"和#34; RFC 822名称"我的客户端身份验证证书中的主题备用名称下的字段?

1 个答案:

答案 0 :(得分:1)

我也长期困扰着这个问题... 我参与了为EFS Recovery Agent生成证书的工作,该字段中存在“使用者备用名称”。 这里当然会写很多有趣的东西,但是不幸的是,没有明确的例子:https://docs.microsoft.com/en-us/powershell/module/pkiclient/new-selfsignedcertificate?view=win10-ps

通过下载功能强大的XCA https://www.hohnstaedt.de/xca/

然后查看为EFS恢复代理生成的cipher.exe / r:证书的内容

生成了OpenSSL所需的字符串

openssl req -x509 -nodes -newkey rsa:4096 -keyout efs.key -out efs.cer -days 36500 -subj '/OU=EFS File Encryption Certificate/L=EFS/CN=efs' -addext 'extendedKeyUsage=1.3.6.1.4.1.311.10.3.4.1' -addext 'basicConstraints=CA:FALSE' -addext 'subjectAltName=otherName:msUPN;UTF8:sb@sb.local'

在这里您将了解如何在“主体名称”和“主题备用名称”之间插入;)

相关问题