的New-SelfSignedCertificate
新版本,其中包括在Windows 10,描述here。可以使用New-SelfSignedCertificate -?
和get-help New-SelfSignedCertificate -examples
来获得一些附加信息。
的文件,并可能似乎仍然没有明确的例子足以建立两个证书:
- 一个自签名的证书,这会从你的例子
- 第二SSL证书作为CA证书,与第一张证书签署。
的实现可能是以下(我写在多行该选项下面才使文本更具可读性):
New-SelfSignedCertificate -HashAlgorithm sha384 -KeyAlgorithm RSA -KeyLength 4096
-Subject "CN=My Test (PowerShell) Root Authority,O=OK soft GmbH,C=DE"
-KeyUsage DigitalSignature,CertSign -NotAfter (get-date).AddYears(10)
-CertStoreLocation "Cert:\CurrentUser\My" -Type Custom
输出将看起来像
Directory: Microsoft.PowerShell.Security\Certificate::CurrentUser\My
Thumbprint Subject
---------- -------
B7DE93CB88E99B01D166A986F7BF2D82A0E541FF CN=My Test (PowerShell) Root Authority, O=OK soft GmbH, C=DE
的值B7DE93CB88E99B01D166A986F7BF2D82A0E541FF
对于使用证书进行签名非常重要。如果你忘记了价值,你可以通过CN名
dir cert:\CurrentUser\My | where Subject -Like "CN=My Test (PowerShell)*"
或使用certutil.exe -user -store My
发现它在我的当前用户的商店中显示的证书。
要创建SSL证书,以及相对于以前创建的证书一个例如可以做的签字下面
New-SelfSignedCertificate -Type Custom -Subject "CN=ok01.no-ip.org"
-HashAlgorithm sha256 -KeyAlgorithm RSA -KeyLength 2048
-KeyUsage KeyEncipherment,DigitalSignature
-CertStoreLocation "cert:\LocalMachine\My"
-Signer cert:\CurrentUser\My\B7DE93CB88E99B01D166A986F7BF2D82A0E541FF
-TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.1,1.3.6.1.5.5.7.3.2","2.5.29.17={text}DNS=ok01.no-ip.org&DNS=ok01.fritz.box")
在我看来,最终的证书将具有所需的所有属性。很显然,来自以上参数的许多值都包含示例,只有您根据自己的要求修改了这些值。我在这里没有描述其他常见步骤,例如在受信任的根中导入根证书,导出证书等等。这些步骤不是你主要问题的psrt。
如果您只使用RSA密钥,则'MakeCert.exe'就足够了,但最好使用'MakeCert.exe'的其他选项。 'New-SelfSignedCertificate'没有任何优势。在互联网上可用的其他Powershell模块可能会更好。您可以使用[OpenSSL.exe](https://www.openssl.org/)而不是'MakeCert.exe'来创建可在IIS上使用的RSA或椭圆曲线证书。如果您的IIS服务器通过互联网(端口80)可用,那么您可以使用Let's Encrypt获得免费的真正的SSL证书,并且客户端不需要将“CA”证书安装在受信任的根目录中。 – Oleg
问题在于使用'New-SelfSignedCertificate'的原因。我不想使用'MakeCert'或'OpenSSL'。 – MovGP0
只需使用start powershell并使用'New-SelfSignedCertificate - ?'和'get-help New-SelfSignedCertificate -examples'。可能性取决于您使用的Windows版本。将https://technet.microsoft.com/en-us/library/hh848633.aspx与https://technet.microsoft.com/en-us/library/hh848633(v=wps.630).aspx – Oleg