C# Class Microsoft.Azure.Commands.RecoveryServices.CertUtils

Class to provide methods to manage the certificates.
Datei anzeigen Open project: Azure/azure-powershell Class Usage Examples

Public Methods

Method Description
CreateSelfSignedCertificate ( int validForHours, string subscriptionId, string certificateNamePrefix, string issuer = DefaultIssuer, string password = DefaultPassword ) : X509Certificate2

Method to generate a self signed certificate

GetCertInBase64EncodedForm ( string certFileName ) : string

Method to get the Certificate's base 64 encoded string

NewX509Certificate2 ( byte rawData, string password, X509KeyStorageFlags keyStorageFlags, bool shouldValidatePfx ) : X509Certificate2

Provides a similar API call to new X509Certificate(byte[],string,X509KeyStorageFlags)

SerializeCert ( X509Certificate2 cert, X509ContentType contentType ) : string

Returns serialized certificate - Base64 encoded based on the content type

Private Methods

Method Description
Create2048RsaKey ( ) : System.Security.Cryptography.CngKey

Windows Azure Service Management API requires 2048bit RSA keys. The private key needs to be exportable so we can save it for sharing with team members.

GenerateCertFriendlyName ( string subscriptionId, string prefix = "" ) : string

Generates friendly name

Method Details

CreateSelfSignedCertificate() public static method

Method to generate a self signed certificate
public static CreateSelfSignedCertificate ( int validForHours, string subscriptionId, string certificateNamePrefix, string issuer = DefaultIssuer, string password = DefaultPassword ) : X509Certificate2
validForHours int number of hours for which the certificate is valid.
subscriptionId string subscriptionId in question
certificateNamePrefix string prefix for the certificate name
issuer string issuer for the certificate
password string certificate password
return System.Security.Cryptography.X509Certificates.X509Certificate2

GetCertInBase64EncodedForm() public static method

Method to get the Certificate's base 64 encoded string
public static GetCertInBase64EncodedForm ( string certFileName ) : string
certFileName string Certificate File Name
return string

NewX509Certificate2() public static method

Provides a similar API call to new X509Certificate(byte[],string,X509KeyStorageFlags)
public static NewX509Certificate2 ( byte rawData, string password, X509KeyStorageFlags keyStorageFlags, bool shouldValidatePfx ) : X509Certificate2
rawData byte The bytes that represent the certificate
password string The certificate private password
keyStorageFlags X509KeyStorageFlags The certificate loading options
shouldValidatePfx bool Flag to indicate if file should validated. Set to true if the rawData is retrieved from an untrusted source.
return System.Security.Cryptography.X509Certificates.X509Certificate2

SerializeCert() public static method

Returns serialized certificate - Base64 encoded based on the content type
public static SerializeCert ( X509Certificate2 cert, X509ContentType contentType ) : string
cert System.Security.Cryptography.X509Certificates.X509Certificate2 The certificate provided
contentType X509ContentType Cert content type
return string