New-KrSelfSignedCertificate

SYNOPSIS

Creates a new self-signed certificate.

SYNTAX

New-KrSelfSignedCertificate [-DnsName] <String[]> [[-KeyType] <String>] [[-KeyLength] <Int32>]
 [[-ValidDays] <Int32>] [-Ephemeral] [-Exportable] [<CommonParameters>]

DESCRIPTION

The New-KrSelfSignedCertificate function generates a self-signed certificate for use in development or testing scenarios. This certificate can be used for securing communications or authentication purposes.

EXAMPLES

EXAMPLE 1

New-KrSelfSignedCertificate -Subject "CN=MyCert" -CertStoreLocation "Cert:\LocalMachine\My"

This example creates a self-signed certificate with the subject “CN=MyCert” and stores it in the local machine’s certificate store.

PARAMETERS

-DnsName

The DNS name(s) for the certificate.

Type: String[]
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-KeyType

The type of key to use for the certificate (RSA or ECDSA).

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 2
Default value: Rsa
Accept pipeline input: False
Accept wildcard characters: False

-KeyLength

The length of the key in bits (only applicable for RSA).

Type: Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: 3
Default value: 2048
Accept pipeline input: False
Accept wildcard characters: False

-ValidDays

The number of days the certificate will be valid.

Type: Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: 4
Default value: 365
Accept pipeline input: False
Accept wildcard characters: False

-Ephemeral

Indicates whether the certificate is ephemeral (temporary).

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

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

-Exportable

Indicates whether the private key is exportable.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

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

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

OUTPUTS

System.Security.Cryptography.X509Certificates.X509Certificate2

NOTES

This function is intended for use in development and testing environments only. Do not use self-signed certificates in production.