Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
powershell是否有创建非自签名证书的工具?_Powershell_Ssl - Fatal编程技术网

powershell是否有创建非自签名证书的工具?

powershell是否有创建非自签名证书的工具?,powershell,ssl,Powershell,Ssl,powershell中有一个名为New SelfSignedCertificate的工具,我们可以为CA创建自签名证书。 但是我不知道是否有可能创建子证书,该子证书由以前通过此新的自签名证书创建的证书颁发/签名。实际上,我可以用makecert.exe来实现这一点,但我想在powershell中编写脚本 例如,在makecert.exe中,我执行以下命令: 1)Creating the CA cert: **makecert.exe** -sk RootCA -sky signature -

powershell中有一个名为
New SelfSignedCertificate
的工具,我们可以为
CA
创建自签名证书。 但是我不知道是否有可能创建子证书,该子证书由以前通过此
新的自签名证书创建的证书颁发/签名。实际上,我可以用
makecert.exe
来实现这一点,但我想在
powershell
中编写脚本

例如,在
makecert.exe
中,我执行以下命令:

 1)Creating the CA cert:  **makecert.exe** -sk RootCA -sky signature -pe -n CN=ca.com -r -sr LocalMachine -ss Root RootCA

 2)Creating another cert for server signed by above CA: **makecert.exe** -sk server -sky exchange -pe -n CN=server.com -ir LocalMachine -is Root -ic RootCA -sr LocalMachine -ss My server.com
在powershell中,我只知道使用该命令创建CA

  New-SelfSignedCertificate -DnsName "ca.com" -CertStoreLocation cert:Localmachine/My
但是,如何创建由上面的证书签名的另一个证书

另外,当我尝试放置
-CertStoreLocation=cert:Localmachine/**Root**
时,我收到一条错误消息,说我只能在我的存储中创建证书(我已经以管理员身份执行)


谢谢。

我很抱歉来晚了,我很清楚这个问题已经问了两年了

但是,要与搜索时可能找到此条目的人共享,现在有一种方法(记录在上)

总之

New-SelfSignedCertificate -certstorelocation cert:\localmachine\my -dnsname "Your root CA name here"
记下此命令返回的指纹

接下来,创建一个安全密码并将根CA导出到一个文件中

动力壳

$pwd = ConvertTo-SecureString -String "Please-Use-A-Really-Strong-Password" -Force -AsPlainText
Export-PfxCertificate -cert cert:\localMachine\my\[CA thumbprint]  -FilePath root-authority.pfx -Password $pwd
Export-Certificate -Cert cert:\localMachine\my\[CA thumbprint] -FilePath root-authority.crt
请注意,crt文件不需要密码,因为它是证书的公共组件

现在将签名证书加载到内存中,并创建一个由该证书签名的证书,并使用密码将其导出

$rootcert = ( Get-ChildItem -Path cert:\LocalMachine\My\[CA Thumbprint] )
New-SelfSignedCertificate -certstorelocation cert:\localmachine\my -dnsname "Your DNS Name Here" -Signer $rootcert
记下自签名证书命令返回的指纹以将其导出

$pwd2 = ConvertTo-SecureString -String "Please-Use-A-Really-Strong-Password" -Force -AsPlainText
    Export-PfxCertificate -cert cert:\localMachine\my\[Cert Thumbprint]  -FilePath gateway-certificate.pfx -Password $pwd2
    Export-Certificate -Cert cert:\localMachine\my\[Cert Thumbprint] -FilePath gateway.crt

手动记录证书的哈希值似乎很麻烦。这样做更简单:

#创建根目录
$rootCert=新的自签名证书-CertStoreLocation证书:\localmachine\my-DnsName“根CA名称”;
#导出根证书
[System.Security.SecureString]$rootcertPassword=converttoSecureString-字符串“znft5yel34pxcu3nat1gmazx0nm8fvrvr9yzohcs79yjm8kuvjha17uuuwkqob0u”-强制-AsPlainText;
[String]$rootCertPath=加入路径-Path'cert:\localMachine\my\'-ChildPath“$($rootcert.Thumbprint)”;
导出PfxCertificate-Cert$rootCertPath-FilePath'root authority.pfx'-Password$rootcertPassword;#私钥
导出证书-Cert$rootCertPath-FilePath“root authority.crt”;#公钥
#使用根证书对网关证书进行签名
$gatewayCert=新的自签名证书-CertStoreLocation证书:\localmachine\my-DnsName“*.example.com”、“*.example.org”-签名者$rootCert;
#出口网关证书
[System.Security.SecureString]$gatewayCertPassword=转换为SecureString-字符串“XC8FLSHQ8HMLNKXK4AAD8UG6HYH2DPSWLJWG9ENEDIK103D3AKBD0OCCGZZB6BL48”-强制-AsPlainText;
[String]$gatewayCertPath=加入路径-Path'cert:\localMachine\my\'-ChildPath“$($gatewayCert.Thumbprint)”;
导出PfxCertificate-Cert$gatewayCertPath-FilePath gateway-certificate.pfx-Password$gatewayCertPassword;#私钥
导出证书-Cert$gatewayCertPath-FilePath gateway.crt;#公钥
另外,对于生产环境,您可能希望使用创建免费TLS证书