New-SelfSignedCertificate (pki) (2024)

  • Reference
Module:
pki

Creates a new self-signed certificate for testing purposes.

Syntax

New-SelfSignedCertificate [-SecurityDescriptor <FileSecurity>] [-TextExtension <String[]>] [-Extension <X509Extension[]>] [-HardwareKeyUsage <HardwareKeyUsage[]>] [-KeyUsageProperty <KeyUsageProperty[]>] [-KeyUsage <KeyUsage[]>] [-KeyProtection <KeyProtection[]>] [-KeyExportPolicy <KeyExportPolicy[]>] [-KeyLength <Int32>] [-KeyAlgorithm <String>] [-SmimeCapabilities] [-ExistingKey] [-KeyLocation <String>] [-SignerReader <String>] [-Reader <String>] [-SignerPin <SecureString>] [-Pin <SecureString>] [-KeyDescription <String>] [-KeyFriendlyName <String>] [-Container <String>] [-Provider <String>] [-CurveExport <CurveParametersExportType>] [-KeySpec <KeySpec>] [-Type <CertificateType>] [-FriendlyName <String>] [-NotAfter <DateTime>] [-NotBefore <DateTime>] [-SerialNumber <String>] [-Subject <String>] [-DnsName <String[]>] [-SuppressOid <String[]>] [-HashAlgorithm <String>] [-AlternateSignatureAlgorithm] [-TestRoot] [-Signer <Certificate>] [-CloneCert <Certificate>] [-CertStoreLocation <String>] [-WhatIf] [-Confirm] [<CommonParameters>]

Description

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

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

Examples

EXAMPLE 1

$params = @{ DnsName = 'www.fabrikam.com', 'www.contoso.com' CertStoreLocation = 'Cert:\LocalMachine\My'}New-SelfSignedCertificate @params

This example creates a self-signed SSL server certificate in the computer MY store with the subjectalternative names www.fabrikam.com and www.contoso.com and the Subject and Issuer name set towww.fabrikam.com.

EXAMPLE 2

Set-Location -Path 'Cert:\LocalMachine\My'PS Cert:\LocalMachine\My> $OldCert = (Get-ChildItem -Path E42DBC3B3F2771990A9B3E35D0C3C422779DACD7)PS Cert:\LocalMachine\My> New-SelfSignedCertificate -CloneCert $OldCert

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

EXAMPLE 3

$params = @{ Type = 'Custom' Subject = 'E=patti.fuller@contoso.com,CN=Patti Fuller' TextExtension = @( '2.5.29.37={text}1.3.6.1.5.5.7.3.4', '2.5.29.17={text}email=patti.fuller@contoso.com&upn=pattifuller@contoso.com' ) KeyAlgorithm = 'RSA' KeyLength = 2048 SmimeCapabilities = $true CertStoreLocation = 'Cert:\CurrentUser\My'}New-SelfSignedCertificate @params

This example creates a self-signed S/MIME certificate in the user MY store. The certificate usesthe default provider, which is the Microsoft Software Key Storage Provider. The certificate usesan RSA asymmetric key with a key size of 2048 bits. This certificate has the subject alternativenames of patti.fuller@contoso.com as RFC822 and pattifuller@contoso.com as Principal Name.

This command does not specify the NotAfter parameter. Therefore, the certificate expires in oneyear.

EXAMPLE 4

$params = @{ Type = 'Custom' Subject = 'CN=Patti Fuller,OU=UserAccounts,DC=corp,DC=contoso,DC=com' TextExtension = @( '2.5.29.37={text}1.3.6.1.5.5.7.3.2', '2.5.29.17={text}upn=pattifuller@contoso.com' ) KeyUsage = 'DigitalSignature' KeyAlgorithm = 'RSA' KeyLength = 2048 CertStoreLocation = 'Cert:\CurrentUser\My'}New-SelfSignedCertificate @params

This example creates a self-signed client authentication certificate in the user MY store. Thecertificate uses the default provider, which is the Microsoft Software Key Storage Provider. Thecertificate uses an RSA asymmetric key with a key size of 2048 bits. The certificate has asubject alternative name of pattifuller@contoso.com.

The certificate expires in one year.

EXAMPLE 5

$params = @{ Type = 'Custom' Subject = 'CN=Patti Fuller,OU=UserAccounts,DC=corp,DC=contoso,DC=com' TextExtension @( '2.5.29.37={text}1.3.6.1.5.5.7.3.2', '2.5.29.17={text}upn=pattifuller@contoso.com' ) KeyUsage = 'DigitalSignature' KeyAlgorithm = 'ECDSA_nistP256' CurveExport = 'CurveName' CertStoreLocation = 'Cert:\CurrentUser\My'}New-SelfSignedCertificate @params

This example creates a self-signed client authentication certificate in the user MY store. Thecertificate uses the default provider, which is the Microsoft Software Key Storage Provider. Thecertificate uses an elliptic curve asymmetric key and the curve parameters nist256, which createsa 256-bit key. The subject alternative name is pattifuller@contoso.com.

The certificate expires in one year.

EXAMPLE 6

$params = @{ Type = 'Custom' Provider = 'Microsoft Platform Crypto Provider' Subject = 'CN=Patti Fuller' TextExtension = @( '2.5.29.37={text}1.3.6.1.5.5.7.3.2', '2.5.29.17={text}upn=pattifuller@contoso.com' ) KeyExportPolicy = 'NonExportable' KeyUsage = 'DigitalSignature' KeyAlgorithm = 'RSA' KeyLength = 2048 CertStoreLocation = 'Cert:\CurrentUser\My'}New-SelfSignedCertificate @params

This example creates a self-signed client authentication certificate in the user MY store. Thecertificate uses the Microsoft Platform Crypto Provider. This provider uses the Trusted PlatformModule (TPM) of the device to create the asymmetric key. The certificate uses an RSA asymmetrickey with a key size of 2048 bits. The key is not exportable. The subject alternative name ispattifuller@contoso.com. The certificate expires in one year.

EXAMPLE 7

$params = @{ Type = 'Custom' Container = 'test*' Subject = 'CN=Patti Fuller' TextExtension = @( '2.5.29.37={text}1.3.6.1.5.5.7.3.2', '2.5.29.17={text}upn=pattifuller@contoso.com' ) KeyUsage = 'DigitalSignature' KeyAlgorithm = 'RSA' KeyLength = 2048 NotAfter = (Get-Date).AddMonths(6)}New-SelfSignedCertificate @params

This example creates a self-signed client authentication certificate in the user MY store. Thecertificate uses the default provider, which is the Microsoft Software Key Storage Provider. Thecertificate uses an RSA asymmetric key with a key size of 2048 bits. The subject alternativename is pattifuller@contoso.com.

This command specifies a value for NotAfter. The certificate expires in six months.

EXAMPLE 8

$params = @{ Type = 'Custom' Subject = 'E=patti.fuller@contoso.com,CN=Patti Fuller' TextExtension = @( '2.5.29.37={text}1.3.6.1.5.5.7.3.4', '2.5.29.17={text}email=patti.fuller@contoso.com&email=pattifuller@contoso.com' ) KeyAlgorithm = 'RSA' KeyLength = 2048 SmimeCapabilities = $true CertStoreLocation = 'Cert:\CurrentUser\My'}New-SelfSignedCertificate @params

This example creates a self-signed S/MIME certificate in the user MY store. The certificate usesthe default provider, which is the Microsoft Software Key Storage Provider. The certificate usesan RSA asymmetric key with a key size of 2048 bits. This certificate has the subject alternativenames of patti.fuller@contoso.com and pattifuller@contoso.com both as RFC822.

This command does not specify the NotAfter parameter. Therefore, the certificate expires in oneyear.

EXAMPLE 9

$params = @{ Subject = 'localhost' TextExtension = @('2.5.29.17={text}DNS=localhost&IPAddress=127.0.0.1&IPAddress=::1')}New-SelfSignedCertificate @params

This example creates a self-signed SSL server certificate with Subject and Issuer name set tolocalhost and with subject alternative name set to IPAddress 127.0.0.1 and ::1 viaTextExtension.

Parameters

-AlternateSignatureAlgorithm

Indicates that this cmdlet uses RSA-PSS (PKCSv2.1) or an elliptic curve cryptography (ECC)equivalent. If you do not specify this parameter, the cmdlet uses the default, RSA-PSS (PKCSv1.5) oran ECC equivalent.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-CertStoreLocation

Specifies the certificate store in which to store the new certificate. If the current path isCert:\CurrentUser or Cert:\CurrentUser\My, the default store is Cert:\CurrentUser\My. If thecurrent path is Cert:\LocalMachine or Cert:\LocalMachine\My, the default store isCert:\LocalMachine\My. Otherwise, you must specify Cert:\CurrentUser\My orCert:\LocalMachine\My for this parameter. This parameter does not support other certificatestores.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-CloneCert

Identifies the certificate to copy when creating a new certificate. The certificate being cloned canbe identified by an X509 certificate or the file path in the certificate provider. When thisparameter is used, all fields and extensions of the certificate will be inherited except theNotAfter and NotBefore fields and the public key. A new key of the same algorithm and lengthwill be created. The default validity period will be the same as the certificate to copy, exceptthat the NotBefore field will be set to ten minutes in the past.

Type:Microsoft.CertificateServices.Commands.Certificate
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Container

Specifies the name of the container in which this cmdlet stores the key for the new certificate.

When you create a key, a trailing asterisk (*) indicates that the rest of the container namestring is a prefix. An appended GUID string makes the container name unique.

When you use an existing key, the container name must identify an existing key.You may also have to specify the provider.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-CurveExport

Specifies how the public key parameters for an elliptic curve key are represented in the newcertificate. The acceptable values for this parameter are:

  • CurveParameters
  • CurveName
  • None

The default value, None, indicates that this cmdlet uses the default value from the underlying keystorage provider (KSP). This parameter is not supported with the RSA algorithm or with cryptographicservice providers (CSPs).

Type:Microsoft.CertificateServices.Commands.CurveParametersExportType
Accepted values:None, CurveParameters, CurveName
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DnsName

Specifies one or more DNS names to put into the subject alternative name extension of thecertificate when a certificate to be copied is not specified via the CloneCert parameter. Thefirst DNS name is also saved as the Subject Name. If no signing certificate is specified, the firstDNS name is also saved as the Issuer Name.

Type:String[]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ExistingKey

Indicates that this cmdlet uses an existing key. If you do not specify this parameter, this cmdletcreates a new key. Creating a certificate from an existing key creates a new key with a newcontainer.

When you use an existing key, specify values for the Container parameter, the Providerparameter, and the CertStoreLocation parameter. CertStoreLocation determines the context.The context is user or computer.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Extension

Specifies an array of certificate extensions, as X509Extension objects, that this cmdletincludes in the new certificate.

Type:X509Extension[]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-FriendlyName

Specifies a friendly name for the new certificate.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-HardwareKeyUsage

Specifies how a hardware key associated with the new certificate may be used. This parameter appliesonly when you specify the Microsoft Platform Crypto Provider. The acceptable values for thisparameter are:

  • None
  • SignatureKey
  • EncryptionKey
  • GenericKey
  • StorageKey
  • IdentityKey

The default value, None, indicates that this cmdlet uses the default value from the underlyingKSP.

Type:Microsoft.CertificateServices.Commands.HardwareKeyUsage[]
Accepted values:None, SignatureKey, EncryptionKey, GenericKey, StorageKey, IdentityKey
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-HashAlgorithm

Specifies the name of the hash algorithm to use to sign the new certificate. The default hashalgorithm depends on the provider that stores the private key used to sign the new certificate.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-KeyAlgorithm

Specifies the name of the algorithm that creates the asymmetric keys that are associated with thenew certificate. Available asymmetric key algorithms are RSA and Elliptic Curve Digital SignatureAlgorithms (ECDSA).

The elliptic curve algorithm syntax is the following:

ECDSA_{curvename}

To obtain a value for {curvename}, use the certutil -displayEccCurve command.

Valid curve names contain a value in the Curve OID column in the output of thecertutil -displayEccCurve command.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-KeyDescription

Specifies a description for the private key that is associated with the new certificate.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-KeyExportPolicy

Specifies the policy that governs the export of the private key that is associated with thecertificate.

The default value of ExportableEncrypted is not compatible with KSP and CSPs that do not allow keyexport. These include the Microsoft Smart Card Key Storage Provider and theMicrosoft Platform Crypto Key Storage Provider. Specify NonExportable for providers that do notallow key export.

Type:Microsoft.CertificateServices.Commands.KeyExportPolicy[]
Accepted values:NonExportable, ExportableEncrypted, Exportable
Position:Named
Default value:ExportableEncrypted
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-KeyFriendlyName

Specifies a friendly name for the private key that is associated with the new certificate.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-KeyLength

Specifies the length, in bits, of the key that is associated with the new certificate.

Type:Int32
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-KeyLocation

Specifies the file system location where this cmdlet stores the private keys associated with the newcertificate. Specify this parameter only when you specify the Microsoft Platform Crypto Provider.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-KeyProtection

Specifies the level of protection required to access the private key that is associated with thecertificate. The acceptable values for this parameter are:

  • Protect
  • ProtectHigh
  • ProtectFingerPrint
  • None

The default value, None, indicates that this cmdlet uses the default value from the underlying KSPor CSP. For most KSPs and CSPs, the default means that no user interface is required to create anduse the private key. A user interface is required if the provider always requires a user interface,such as a smart card, or if the default configuration of the provider has been changed.

Type:Microsoft.CertificateServices.Commands.KeyProtection[]
Accepted values:None, Protect, ProtectHigh, ProtectFingerPrint
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-KeySpec

Specifies whether the private key associated with the new certificate can be used for signing,encryption, or both. The acceptable values for this parameter are:

  • KeyExchange
  • Signature
  • None

The default value, None, indicates that this cmdlet uses the default value from the underlyingCSP.

If the private key is managed by a legacy CSP, the value is KeyExchange or Signature. If the keyis managed by a Cryptography Next Generation (CNG) KSP, the value is None.

Type:Microsoft.CertificateServices.Commands.KeySpec
Accepted values:None, KeyExchange, Signature
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-KeyUsage

Specifies the key usages set in the key usage extension of the certificate. The acceptable valuesfor this parameter are:

  • CertSign
  • CRLSign
  • DataEncipherment
  • DecipherOnly
  • DigitalSignature
  • EncipherOnly
  • KeyAgreement
  • KeyEncipherment
  • None
  • NonRepudiation

The value, None, indicates that this cmdlet does not include the KeyUsage extension in the newcertificate.

Type:Microsoft.CertificateServices.Commands.KeyUsage[]
Accepted values:None, EncipherOnly, CRLSign, CertSign, KeyAgreement, DataEncipherment, KeyEncipherment, NonRepudiation, DigitalSignature, DecipherOnly
Position:Named
Default value:DigitalSignature,KeyEncipherment
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-KeyUsageProperty

Specifies the key usages for the key usages property of the private key. The acceptable values forthis parameter are:

  • All
  • Decrypt
  • KeyAgreement
  • None
  • Sign

The default value, None, indicates that this cmdlet uses the default value from the underlyingKSP.

Type:Microsoft.CertificateServices.Commands.KeyUsageProperty[]
Accepted values:None, Decrypt, Sign, KeyAgreement, All
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-NotAfter

Specifies the date and time, as a DateTime object, that the certificate expires. To obtain aDateTime object, use the Get-Date cmdlet. The default value for this parameter is one yearafter the certificate was created.

Type:DateTime
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-NotBefore

Specifies the date and time, as a DateTime object, when the certificate becomes valid. Thedefault value for this parameter is 10 minutes before the certificate was created.

Type:DateTime
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Pin

Specifies the personal identification number (PIN) used to access the private key of the newcertificate.

Type:System.SecureString
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Provider

Specifies the name of the KSP or CSP that this cmdlet uses to create the certificate. SeeCryptographic Providers formore information. Some acceptable values include:

  • Microsoft Software Key Storage Provider
  • Microsoft Smart Card Key Storage Provider
  • Microsoft Platform Crypto Provider
  • Microsoft Strong Cryptographic Provider
  • Microsoft Enhanced Cryptographic Provider v1.0
  • Microsoft Enhanced RSA and AES Cryptographic Provider
  • Microsoft Base Cryptographic Provider v1.0
  • The name of a third party KSP or CSP
Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Reader

Specifies the name of the smart card reader on which to store the private key for the newcertificate.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-SecurityDescriptor

Specifies the private key security descriptor as a FileSecurity object. Read access is requiredto use the private key. This parameter does not apply to providers that do not support securitydescriptors on private keys, including the smart card CSP and smart card KSP.

Type:FileSecurity
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-SerialNumber

Specifies a serial number, as a hexadecimal string, that is associated with the new certificate. Ifyou do not specify this parameter, this cmdlet assigns a pseudo-randomly generated 16-byte value.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Signer

Specifies a Certificate object with which this cmdlet signs the new certificate. This value mustbe in the Personal certificate store of the user or device. This cmdlet must have read access to theprivate key of the certificate.

Type:Microsoft.CertificateServices.Commands.Certificate
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-SignerPin

Specifies the PIN that is required to access the private key of the certificate that is used to signthe new certificate.

Type:System.SecureString
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-SignerReader

Specifies the name of the smart card reader that is used to sign the new certificate.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-SmimeCapabilities

Indicates that the new certificate includes available encryption algorithms to a Secure/MultipurposeInternet Mail Extensions (S/MIME) capabilities extension.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Subject

Specifies the string that appears in the subject of the new certificate. This cmdlet prefixes CN=to any value that does not contain an equal sign. For multiple subject relative distinguished names(also known as RDNs), separate each subject relative distinguished name with a comma (,). If thevalue of the relative distinguished name contains commas, separate each subject relativedistinguished name with a semicolon (;).

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-SuppressOid

Specifies an array of object identifier (also known as OID) strings that identify default extensionsto be removed from the new certificate.

Type:String[]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-TestRoot

Indicates that this cmdlet signs the new certificate by using a built-in test certificate. Thiscmdlet adds the built-in test certificate to the intermediate certification authority (CA)certificate store of the device.

This parameter is for test purposes only. The private key of the test root certificate isessentially public.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-TextExtension

Specifies an array of certificate extensions, as strings, which this cmdlet includes in the newcertificate. Each string must employ one of the following formats:

{oid}={base64String}, where {oid} is the object identifier of the extension and {base64String}is a value that you provide. After decoding {base64String}, the value must be valid AbstractSyntax Notation One (ASN.1). For more information, seeAbstract Syntax Notation One (ASN.1): Specification of basic notation.

{oid}={hex}{hexadecimalString}, where {oid} is the object identifier of the extension and{hexadecimalString} is a value that you provide. After decoding {hexadecimalString}, the valuemust be valid ASN.1.

{oid}={text}{String}, where {oid} is the object identifier of the extension and {String} is avalue that you provide. {String} must contain a textual representation of the extension value in aformat specific to each object ID. When {String} is processed, it will be encoded into an ASN.1extension value before being placed into the new certificate as an extension.

To specify that an extension is critical, insert {critical} immediately following {oid}= in anyof the previous cases.

The object identifiers of some common extensions are as follows:

  • Application Policy: 1.3.6.1.4.1.311.21.10
  • Application Policy Mappings: 1.3.6.1.4.1.311.21.11
  • Basic Constraints: 2.5.29.19
  • Certificate Policies: 2.5.29.32
  • Enhanced Key Usage: 2.5.29.37
  • Name Constraints: 2.5.29.30
  • Policy Mappings: 2.5.29.33
  • Subject Alternative Name: 2.5.29.17

Application Policy extension example: 1.3.6.1.4.1.311.21.10={text}{token}={value}&{token}={value}...

You can specify the following tokens in an Application Policy extension:

  • Flags: Bitwise flags in hexadecimal notation: 0x{hexadecimalNumber}
  • GUID: A globally unique ID, such as this example: f7c3ac41-b8ce-4fb4-aa58-3d1dc0e36b39
  • Notice: Text notice
  • OID: Object identifier in dotted decimal notation, such as this example: 1.2.3.4.5
  • URL: The URL of a host, such as this example: http://computer07.contoso.com

To specify an Application Policy extension, specify the first object identifier, followed by zero ormore other {token}={value} entries. These entries are subordinate to the preceding objectidentifier. Specify subsequent object identifiers, each followed by its subordinate{token}={value} entries.

Application Policy Mappings extension example: 1.3.6.1.4.1.311.21.11={text}oid={oid}&oid={oid}...

Certificate Policies extension example: 2.5.29.32={text}{token}={value}&{token}={value}...

You can specify the following tokens in a Certificate Policies extension:

  • Flags: Bitwise flags in hexadecimal notation: 0x{hexadecimalNumber}
  • GUID: A globally unique ID, such as this example: f7c3ac41-b8ce-4fb4-aa58-3d1dc0e36b39
  • Notice: Text notice
  • OID: Object identifier in dotted decimal notation, such as this example: 1.2.3.4.5
  • URL: The URL of a host, such as this example: http://computer07.contoso.com

To specify a Certificate Policies extension, follow the same syntax as an Application Policyextension.

Enhanced Key Usage Object Identifiers extension example: 2.5.29.37={text}{oid},{oid}...

These key usages have the following object identifiers:

  • Client Authentication: 1.3.6.1.5.5.7.3.2
  • Server Authentication: 1.3.6.1.5.5.7.3.1
  • Secure Email: 1.3.6.1.5.5.7.3.4
  • Code Signing: 1.3.6.1.5.5.7.3.3
  • Timestamp Signing: 1.3.6.1.5.5.7.3.8

Name Constraints extension example:2.5.29.30={text}subtree=include&{token}={value}&{token}={value}&subtree=exclude&{token}={value}...

A Name Constraints extension can have Subtree values of Include and Exclude to specifyincluded and excluded names.

You can specify the following tokens in a Name Constraints extension:

  • DirectoryName: A distinguished name such as: CN=Name,DC=Domain,DC=com
  • DNS: A computer name in the following format: computer.contoso.com
  • Email: An email address, such as this example: admin@contoso.com
  • IPAddress: {IPV4 address},{IPV4 subnet mask} or {IPV6 address},{IPV6 subnet mask}
  • RegisteredID: ID in dotted decimal notation, such as this example: 1.2.3.4.5
  • UPN: A user principal name in the following format: admin@contoso.com
  • URL: The URL of a host, such as this example: http://computer07.contoso.com/index.html

Policy Mapping extension example: 2.5.29.33={text}oid={oid}&oid={oid}...

Subject Alternative Name extension example: 2.5.29.17={text}token=value&token=value...

You can specify the following tokens in a Subject Alternative Name extension:

  • DirectoryName: A distinguished name such as: CN=Name,DC=Domain,DC=com
  • DNS: A computer name in the following format: computer.contoso.com
  • Email: An email address, such as this example: admin@contoso.com
  • GUID: A globally unique ID, such as this example: f7c3ac41-b8ce-4fb4-aa58-3d1dc0e36b39
  • IPAddress: {IPV4 address},{IPV4 subnet mask} or {IPV6 address},{IPV6 subnet mask}
  • RegisteredID: ID in dotted decimal notation, such as this example: 1.2.3.4.5
  • UPN: A user principal name in the following format: admin@contoso.com
  • URL: The URL of a host, such as this example: http://computer07.contoso.com/index.html
Type:String[]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Type

Specifies the type of certificate that this cmdlet creates.

Type:Microsoft.CertificateServices.Commands.CertificateType
Accepted values:Custom, CodeSigningCert, DocumentEncryptionCert, SSLServerAuthentication, DocumentEncryptionCertLegacyCsp
Position:Named
Default value:SSLServerAuthentication
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

Microsoft.CertificateServices.Commands.Certificate

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

Outputs

X509Certificate2

An X509Certificate2 object for the certificate that has been created.

  • System Store Locations
New-SelfSignedCertificate (pki) (2024)

FAQs

How to use a new-SelfSignedCertificate? ›

Creating self-signed SSL certificates
  1. Open the PowerShell Console in admin mode.
  2. Use the cmdlet New-SelfSignedCertificate to create a self-signed certificate. Copy Code. Code. New-SelfSignedCertificate -DnsName "server.domain.test" -CertStoreLocation "cert:\LocalMachine\My"
  3. Optional: Copy the thumbprint for later use.
Jun 14, 2023

How to create a self-signed certificate with longer than 1 year? ›

To create self-signed certificate with a specific validity, you can create it with 'NotBefore' and 'NotAfter' parameters. For example, the below cmdlet creates certificate with 36 months validity. The above cmd creates a certificate with 5 years validity.

How to create a self-signed certificate with private key? ›

To generate a self-signed certificate file on a Windows system:
  1. You will need to have OpenSSL installed.
  2. Open a command prompt window and go to the directory you created earlier for the public/private key file. ...
  3. Enter the path of the OpenSSL install directory, followed by the self-signed certificate algorithm.

Does a self-signed certificate expire? ›

As mentioned earlier, your own certificates don't need to be renewed because they never expire.

What is the purpose of a self-signed certificate? ›

Definitions: A public-key certificate whose digital signature may be verified by the public key contained within the certificate. The signature on a self-signed certificate protects the integrity of the information within the certificate but does not guarantee the authenticity of that information.

What is the biggest issue with a self-signed certificate? ›

The biggest challenge with self-signed certificates is the Lack of visibility.

How do I replace a self-signed certificate? ›

Replace Self-signed Certificate
  1. Run the following commands to export the private key. *openssl pkcs12 -in certificate.pfx -nocerts -out securden-key.pem - nodes* *openssl rsa -in securden-key.pem -out securden-key.pem*
  2. Run the following command to export the certificate.

How to increase the validity of a self-signed certificate? ›

Summary. When creating a new self-signed certificate and keystore using Java's keytool command, the default validity is 90 days. In order to extend this, you can modify the keystore creation command to include the validity parameter.

How to generate a self-signed certificate in Windows using OpenSSL? ›

Introduction
  1. Step 1: Install and run OpenSSL. ...
  2. Step 2: Generate the root private key. ...
  3. Step 3: Create a self-signed certificate. ...
  4. Step 4: Install the root certificate on the workstation(s) ...
  5. Step 5: Create a private key. ...
  6. Step 6: Generate the certificate signing request. ...
  7. Step 7: Upload the certificates to your Teramind server.

Which command do you use to create a self-signed certificate? ›

The New-SelfSignedCertificate cmdlet creates a self-signed certificate for testing purposes.

How do I make a self-signed certificate valid? ›

Adding a self-signed certificate to the Server application
  1. Create a new file via a text editor and save it as cert. pem. ...
  2. Open the cert. pem file and add the contents of files created in step 1 to the cert. ...
  3. Stop the server application. ...
  4. Move the cert. ...
  5. Start the server application.
Feb 29, 2024

Is PKI outdated? ›

However, PKI has a number of weaknesses that make it unsuitable for use today. It may is no longer considered to be an effective security measure.

How do I add a PKI signature? ›

Sign your PDF document with a digital signature according to the protocols of Public Key Infrastructure (PKI).
  1. Open your PDF document.
  2. Right-click in the PDF document where you want to add the Digital signature.
  3. Select Sign Document from the right-click menu. ...
  4. Select Digital Signature.

What is the difference between a certificate and a PKI? ›

A digital certificate works like a passport or driver's license by proving your identity and providing certain allowances. The purpose of a PKI is to facilitate the secure electronic transfer of information for a range of network activities such as e-commerce, internet banking, and confidential email.

How do I add a self-signed SSL certificate? ›

Adding a self-signed certificate to the Server application
  1. Create a new file via a text editor and save it as cert. pem. ...
  2. Open the cert. pem file and add the contents of files created in step 1 to the cert. ...
  3. Stop the server application. ...
  4. Move the cert. ...
  5. Start the server application.
Feb 29, 2024

How to generate a self-signed certificate in Windows 10 using? ›

Using IIS
  1. From the top-level in IIS Manager, select “Server Certificates”;
  2. Then click the “Create” button on the right;
  3. This will create a self-signed certificate, valid for a year with a private key. It will only work for “localhost”.
Feb 11, 2024

What is the use of a self-signed certificate in Salesforce? ›

Self-signed certificates are commonly used for Single Sign-On settings (in 'Request Signing Certificate' or 'Assertion Decryption Certificate' field) or callouts to external sites (for client authentication).

How to export a self-signed certificate? ›

Export the Self-Signed Certificate

On the Certificate Export Wizard welcome screen, click Next. On the Export Private Key screen, select No, do not export the private key. Only export the certificate.

Top Articles
Latest Posts
Article information

Author: Horacio Brakus JD

Last Updated:

Views: 6674

Rating: 4 / 5 (51 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Horacio Brakus JD

Birthday: 1999-08-21

Address: Apt. 524 43384 Minnie Prairie, South Edda, MA 62804

Phone: +5931039998219

Job: Sales Strategist

Hobby: Sculling, Kitesurfing, Orienteering, Painting, Computer programming, Creative writing, Scuba diving

Introduction: My name is Horacio Brakus JD, I am a lively, splendid, jolly, vivacious, vast, cheerful, agreeable person who loves writing and wants to share my knowledge and understanding with you.