New-SelfSignedCertificate

New-SelfSignedCertificate

Creates a new self-signed certificate for testing purposes.

语法

Parameter Set: Default
New-SelfSignedCertificate [-CertStoreLocation <String> ] [-CloneCert <Certificate> ] [-DnsName <String> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

详细说明

The New-SelfSignedCertificate cmdlet creates a self-signed certificate for testing purposes. Using the CloneCert parameter, a test certificate can be created based on an existing certificate with all settings copied from the original certificate except for the public key. A new key of the same algorithm and length will be created.

If an existing certificate is not being cloned, then an SSL server certificate with the following default settings is created:
-- Subject: Empty
-- Key: RSA 2048
-- EKUs: Client Authentication and Server Authentication
-- Key Usage: Digital Signature, Key Encipherment (a0)
-- Validity Period: One year

Delegation may be required when using this cmdlet with Windows PowerShell remoting and changing user configuration.

参数

-CertStoreLocation<String>

Specifies the certificate store in which a new certificate will be stored. The current path is the default value.

别名

是否为必需?

false

位置?

named

默认值

.

是否接受管道输入?

false

是否接受通配符?

false

-CloneCert<Certificate>

Identifies the certificate to copy when creating a new certificate. The certificate being cloned can be identified by an X509 certificate or the file path in the certificate provider. When this parameter is used, all fields and extensions of the certificate will be inherited except the public key (a new key of the same algorithm and length will be created) and the NotAfter and NotBefore fields (the validity period for the NotBefore field is set to ten minutes in the past).

别名

是否为必需?

false

位置?

named

默认值

是否接受管道输入?

true (ByValue)

是否接受通配符?

false

-DnsName<String>

Specifies one or more DNS names to put into the Subject Alternative Name extension of the certificate when a certificate to be copied is not specified via the CloneCert parameter. The first DNS name is also saved as Subject Name and Issuer Name.

别名

是否为必需?

false

位置?

named

默认值

是否接受管道输入?

false

是否接受通配符?

false

-Confirm

运行 cmdlet 之前提示你进行确认。

是否为必需?

false

位置?

named

默认值

false

是否接受管道输入?

false

是否接受通配符?

false

-WhatIf

显示如果运行 cmdlet 则会发生什么情况。cmdlet 未运行。

是否为必需?

false

位置?

named

默认值

false

是否接受管道输入?

false

是否接受通配符?

false

<CommonParameters>

此 cmdlet 支持通用参数:-Verbose、-Debug、-ErrorAction、-ErrorVariable、-OutBuffer 和 -OutVariable。有关详细信息,请参阅 about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216).

输入

输入类型是指可通过管道传送给 cmdlet 的对象的类型。

  • Microsoft.CertificateServices.Commands.Certificate

    The Certificate object can either be provided as a Path object to a certificate or a X509Certificate2 object.

输出

输出类型是 cmdlet 所发出对象的类型。

  • System.Security.Cryptography.X509Certificates.X509Certificate2

    A X509Certificate2 object for the certificate that has been created.

示例

EXAMPLE 1

This example creates a self-signed SSL server certificate in the computer MY store with the Subject Alternative Name set to www.fabrikam.com, www.contoso.com and Subject and Issuer name set to www.fabrikam.com.

PS C:\> New-SelfSignedCertificate -DnsName www.fabrikam.com, www.contoso.com -CertStoreLocation cert:\LocalMachine\My

EXAMPLE 2

This example creates a copy of the certificate specified by the CloneCert parameter and puts it in the computer MY store.

PS C:\> Set-Location -Path cert:\LocalMachine\My
PS C:\> $copyOf = (Get-ChildItem -Path E42DBC3B3F2771990A9B3E35D0C3C422779DACD7)
PS C:\> New-SelfSignedCertificate -CloneCert $copyOf

相关主题

Get-ChildItem

Set-Location