AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1002185
Accepted
bug_2
bug_2
Asked: 2020-02-08 03:50:55 +0800 CST2020-02-08 03:50:55 +0800 CST 2020-02-08 03:50:55 +0800 CST

使用 OpenSSL 为 IIS 上的 localhost 生成最终实体证书

  • 772

请问如何根据自己的CA根证书生成端实体证书?我以这种方式生成了根 CA:

openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes \
    -keyout example.key -out example.crt -subj /CN=MyCompany \
    -addext subjectAltName=IP:192.168.100.82

openssl pkcs12 -export -out cert.pfx -inkey example.key -in example.crt

我已将 cer 文件导入Windows Trusted Root Certification Authorities并将 pfx 文件导入IIS Server Certificates。

它适用于 Chrome、IE 和 Edge,但 Firefox 报告我的证书存在问题:MOZILLA_PKIX_ERROR_CA_CERT_USED_AS_END_ENTITY

我用谷歌搜索了它,我了解到我应该拥有由我的 CA 根证书签名的最终实体证书。我试图生成最终实体证书:

openssl genrsa -out server.key 4096
openssl req -new -key server.key -out server.csr -subj /CN=MyCompanyEE -addext subjectAltName=IP:192.168.100.82
openssl x509 -req -in server.csr -CA cert.pem -CAkey example.key -CAcreateserial -out server.crt -days 3650 -sha256
openssl pkcs12 -export -out server.pfx -inkey server.key -in server.crt

OpenSSL 响应:

Signature ok
subject=CN = MyCompanyEE
Getting CA Private Key

我也已将 server.pfx 导入IIS 服务器证书,并将我的 Web 应用程序的绑定更改为使用服务器证书,但现在它在 Firefox 或 Chrome 中都不起作用。

Firefox 说:SSL_ERROR_BAD_CERT_DOMAIN,

Chrome 说:NET::ERR_CERT_COMMON_NAME_INVALID。

我做错了什么?

ssl-certificate openssl iis-10 self-signed-certificate
  • 1 1 个回答
  • 3330 Views

1 个回答

  • Voted
  1. Best Answer
    bug_2
    2020-02-19T01:24:51+08:002020-02-19T01:24:51+08:00

    我无法使用 OpenSSL 为本地网站生成证书(可在 192.168.100.82:997 的 Intranet 中获得)所以 - 根据@Crypt32 的建议 - 我改变了方法并使用了 PowerShell。您可以在下面找到我的工作解决方案:

    1. 以管理员身份运行 PowerShell 。
    2. 使用以下代码生成自签名根授权 (MyCompany CA) 和服务器 (MyCompany) 证书:

      $authorityCert = New-SelfSignedCertificate `
      -Subject "CN=MyCompany CA,OU=IT,O=MyCompany Certificate Authority,C=US" `
      -KeyAlgorithm RSA `
      -KeyLength 4096 `
      -KeyUsage CertSign, CRLSign, DigitalSignature, KeyEncipherment, DataEncipherment `
      -KeyExportPolicy Exportable `
      -NotBefore (Get-Date) `
      -NotAfter (Get-Date).AddYears(10) `
      -HashAlgorithm SHA256 `
      -CertStoreLocation "Cert:\LocalMachine\My" `
      -FriendlyName "MyCompany CA" `
      -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.1", "2.5.29.19={critical}{text}ca=1")
      
      $devCert = New-SelfSignedCertificate `
      -Subject "CN=MyCompany,OU=App Test,O=MyCompany,C=US" `
      -KeyAlgorithm RSA `
      -KeyLength 4096 `
      -KeyUsage DigitalSignature, KeyEncipherment, DataEncipherment `
      -KeyExportPolicy Exportable `
      -NotBefore (Get-Date) `
      -NotAfter (Get-Date).AddYears(10) `
      -HashAlgorithm SHA256 `
      -CertStoreLocation "Cert:\LocalMachine\My" `
      -FriendlyName "MyCompany" `
      -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.1", "2.5.29.17={text}IPAddress=192.168.100.82") `
      -Signer $authorityCert
      
      $directory = "C:\Users\bug_2\Certificates\"
      if(!(test-path $directory))
      {
        New-Item -ItemType Directory -Force -Path $directory
      }
      $authorityCertPath = 'Cert:\LocalMachine\My\' + ($authorityCert.ThumbPrint)
      $authorityCertFilename = $directory + "Authority.cer"
      Export-Certificate -Cert $authorityCertPath -FilePath $authorityCertFilename
      $devCertPath = 'Cert:\LocalMachine\My\' + ($devCert.ThumbPrint)
      $devCertFilename = $directory + "Dev.cer"
      Export-Certificate -Cert $devCertPath -FilePath $devCertFilename
      
    3. 按 WIN+R 将根证书添加到系统中的受信任的根证书颁发机构,键入:mmc,按 ENTER。在Microsoft 管理控制台中选择File->Add or Remove Snap-ins,然后在新窗口中选择Certificates -> Add -> OK. 展开Certificates->Trusted Root Certification Authorities。右键单击放置在受信任的根证书颁发机构内的证书目录,然后选择并从中选择文件。应用更改并关闭Microsoft 管理控制台。All Tasks->Import...Authority.cerC:\Users\bug_2\Certificates\

    4. 您无需任何额外步骤即可在 IIS 中找到您的新证书(根证书和服务器证书)。在 IIS 中选择您的网站,单击Bindings...->Edit并选择服务器证书 (MyCompany)。应用更改。

    5. 我的网站现在可以在https://192.168.100.82:997除 Firefox 之外的所有网络浏览器(如 Chrome、IE、Edge)上使用。对于运行 Firefox 的修复,about:config在地址栏中输入并设置security.enterprise_roots.enabled为 true。重启火狐。

    现在我的本地网站在https://192.168.100.82:997的 Intranet 中可用。

    • 1

相关问题

  • RHEL/Apache ssl.conf 配置问题

  • IIS7 中的证书信任列表

  • SSL证书的区别?

  • 如何修复邮件服务器 SSL?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve