CertificateRequestProperties class

Applies to Windows and Windows Phone

Represents the properties of a certificate request.

Syntax


public sealed class CertificateRequestProperties

Attributes

[DualApiPartition()]
[MarshalingBehavior(Agile)]
[Threading(Both)]
[Version(0x06020000)]

Members

The CertificateRequestProperties class has these types of members:

Constructors

The CertificateRequestProperties class has these constructors.

ConstructorDescription
CertificateRequestProperties Creates and initializes a new instance of the CertificateRequestProperties.

 

Methods

The CertificateRequestProperties class inherits methods from the Object class (C#/VB/C++).

Properties

The CertificateRequestProperties class has these properties.

PropertyAccess typeDescription

AttestationCredentialCertificate

Read/writeGets or sets the CA exchange certificate that is used to encrypt a key attestation certificate request.

Exportable

Read/writeGets or sets a value that specifies whether the private key created for the request can be exported.

FriendlyName

Read/writeGets or sets the display name of the enrolled certificate.

HashAlgorithmName

Read/writeGets or sets the hash algorithm used when creating the certificate request signature.

KeyAlgorithmName

Read/writeGets or sets the public key algorithm.

KeyProtectionLevel

Read/writeGets or sets the level of strong key protection.

KeySize

Read/writeGets or sets the size, in bits, of the private key to be generated.

KeyStorageProviderName

Read/writeGets or sets the name of the key storage provider (KSP) that will be used to generate the private key.

KeyUsages

Read/writeGets or sets the operation that can be performed by the private key created for this certificate request. The default value is Signing.

SigningCertificate

Read/writeGets or sets the certificate used to sign the certificate request.

SmartcardReaderName

Read/writeGets or sets the name of the smart card reader used to create the certificate request.

Subject

Read/writeGets or sets the subject name.

 

Examples


using Windows.Security.Cryptography.Certificates;
using System.Threading.Tasks;

namespace SampleCertificateRequestProperties
{

    sealed partial class CertificateRequestPropertiesApp : Application
    {
        public CertificateRequestPropertiesApp()
        {
            // Initialize the application
            this.InitializeComponent();

            // Set and retrieve the export option.
            ExportOption exportable = this.GetSetExportable(ExportOption.Exportable);

            // Set and retrieve the display name.
            String strDisplayName = this.GetSetDisplayName("NewDisplayName");

            // Set and retrieve the hashing algorithm name.
            String strHashAlgName = this.GetSetHashAlgorithm(HashAlgorithmNames.Sha512);

            // Set and retrieve the public key algorithm name.
            String strPublicKeyAlgName = this.GetSetPublicKeyAlgorithm(KeyAlgorithmNames.Ecdsa384);

            // Set and retrieve the key protection level.
            KeyProtectionLevel level = this.GetSetKeyProtectionLevel(KeyProtectionLevel.ConsentWithPassword);

            // Set and retrieve the size, in bits, of the private key.
            UInt32 keySize = this.GetSetKeySize(4096);

            // Set and retrieve the name of the key storage provider.
            String strKspName = this.GetSetKspName(KeyStorageProviderNames.PlatformKeyStorageProvider);

            // Set and retrieve the key usage.
            EnrollKeyUsages keyUse = this.GetSetKeyUsage(EnrollKeyUsages.Decryption);

            // Set and retrieve the certificate subject name.
            String strSubject = this.GetSetSubjectName("NewSubjectName");
        }

        public ExportOption GetSetExportable(ExportOption inputOption)
        {
            // Create a new CertificateRequestProperties object.
            CertificateRequestProperties reqProperties = new CertificateRequestProperties();
            
            // The default value is ExportOption.NotExportable
            ExportOption defaultOption = reqProperties.Exportable;

            // If the input option does not equal the default option, reset the property value.
            if (inputOption != defaultOption)
            {
                reqProperties.Exportable = inputOption;
            }

            // Return the option value.
            return reqProperties.Exportable;
        }

        public String GetSetDisplayName(String strDisplayNameIn)
        {
            // Create a new CertificateRequestProperties object.
            CertificateRequestProperties reqProperties = new CertificateRequestProperties();
            
            // The default value is an empty string.
            String defaultName = reqProperties.FriendlyName;

            // If the input option does not equal the default option, reset the property value.
            if (strDisplayNameIn != defaultName)
            {
                reqProperties.FriendlyName = strDisplayNameIn;
            }

            // Return the display name.
            return reqProperties.FriendlyName;

        }

        public String GetSetHashAlgorithm(String strAlgNameIn)
        {
            // Create a new CertificateRequestProperties object.
            CertificateRequestProperties reqProperties = new CertificateRequestProperties();

            // The default value is SHA256.
            String strDefaultAlgName = reqProperties.HashAlgorithmName;

            // If the input option does not equal the default option, reset the property value.
            if (strAlgNameIn != strDefaultAlgName)
            {
                reqProperties.HashAlgorithmName = strAlgNameIn;
            }

            // Return the algorithm name.
            return reqProperties.HashAlgorithmName;
        }

        public String GetSetPublicKeyAlgorithm(String strAlgNameIn)
        {
            // Create a new CertificateRequestProperties object.
            CertificateRequestProperties reqProperties = new CertificateRequestProperties();

            // The default value is RSA.
            String strDefaultAlgName = reqProperties.KeyAlgorithmName;

            // If the input option does not equal the default option, reset the property value.
            if (strAlgNameIn != strDefaultAlgName)
            {
                reqProperties.KeyAlgorithmName = strAlgNameIn;
            }

            // Return the algorithm name.
            return reqProperties.KeyAlgorithmName;
        }

        public KeyProtectionLevel GetSetKeyProtectionLevel(KeyProtectionLevel levelIn)
        {
            // Create a new CertificateRequestProperties object.
            CertificateRequestProperties reqProperties = new CertificateRequestProperties();

            // The default value is NoConsent.
            KeyProtectionLevel defaultLevel = reqProperties.KeyProtectionLevel;

            // If the input option does not equal the default option, reset the property value.
            if (levelIn != defaultLevel)
            {
                reqProperties.KeyProtectionLevel = levelIn;
            }

            // return the key protection level.
            return reqProperties.KeyProtectionLevel;
        }

        public UInt32 GetSetKeySize(UInt32 sizeIn)
        {
            // Create a new CertificateRequestProperties object.
            CertificateRequestProperties reqProperties = new CertificateRequestProperties();

            // The default value is 2048 bits.
            UInt32 uDefaultSize = reqProperties.KeySize;

            // If the input option does not equal the default option, reset the property value.
            if (SizeIn != uDefaultSize)
            {
                reqProperties.KeySize = SizeIn;
            }

            // Return the key size.
            return reqProperties.KeySize;
        }

        public String GetSetKspName(String strNameIn)
        {
            // Create a new CertificateRequestProperties object.
            CertificateRequestProperties reqProperties = new CertificateRequestProperties();

            // The default value is Microsoft Software Key Storage Provider.
            String strDefaultName = reqProperties.KeyStorageProviderName;

            // If the input option does not equal the default option, reset the property value.
            if (strNameIn != strDefaultName)
            {
                reqProperties.KeyStorageProviderName = strNameIn;
            }

            // Return the KSP name.
            return reqProperties.KeyStorageProviderName;
        }

        public EnrollKeyUsages GetSetKeyUsage(EnrollKeyUsages keyUseIn)
        {
            // Create a new CertificateRequestProperties object.
            CertificateRequestProperties reqProperties = new CertificateRequestProperties();

            // The default value is signing.
            EnrollKeyUsages defaultKeyUse = reqProperties.KeyUsages;

            // If the input option does not equal the default option, reset the property value.
            if (keyUseIn != defaultKeyUse)
            {
                reqProperties.KeyUsages = keyUseIn;
            }

            // Return the value.
            return reqProperties.KeyUsages;
        }

        public String GetSetSubjectName(String strNameIn)
        {
            // Create a new CertificateRequestProperties object.
            CertificateRequestProperties reqProperties = new CertificateRequestProperties();

            // The default value is an empty string.
            String strDefaultName = reqProperties.Subject;

            // If the input option does not equal the default option, reset the property value.
            if (strNameIn != strDefaultName)
            {
                reqProperties.Subject = strNameIn;
            }

            // Return the subject name.
            return reqProperties.Subject;
        }
    }
}


Requirements

Minimum supported client

Windows 8 [Windows Store apps, desktop apps]

Minimum supported server

Windows Server 2012 [Windows Store apps, desktop apps]

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.Security.Cryptography.Certificates
Windows::Security::Cryptography::Certificates [C++]

Metadata

Windows.winmd

See also

Windows.Security.Cryptography.Certificates

 

 

Show:
© 2014 Microsoft