CertificateRequest.CreateSigningRequest Method

Definition

Overloads

CreateSigningRequest()

Creates an ASN.1 DER-encoded PKCS#10 CertificationRequest value representing the state of the current object.

CreateSigningRequest(X509SignatureGenerator)

Creates an ASN.1 DER-encoded PKCS#10 CertificationRequest representing the current state of the current object using the provided signature generator.

CreateSigningRequest()

Creates an ASN.1 DER-encoded PKCS#10 CertificationRequest value representing the state of the current object.

public:
 cli::array <System::Byte> ^ CreateSigningRequest();
public byte[] CreateSigningRequest ();
member this.CreateSigningRequest : unit -> byte[]
Public Function CreateSigningRequest () As Byte()

Returns

Byte[]

A DER-encoded certificate signing request.

Exceptions

The current object was created using a constructor that doesn't accept a signing key.

Remarks

When submitting a certificate signing request via a web browser, or other graphical or textual interface, the input is frequently expected to be in the Privacy Enhanced Mail (PEM) format, instead of the DER binary format. To convert the return value to PEM format, make a string consisting of -----BEGIN CERTIFICATE REQUEST-----, a newline, the Base-64-encoded representation of the request (by convention, linewrapped at 64 characters), a newline, and -----END CERTIFICATE REQUEST-----.

public static string PemEncodeSigningRequest(CertificateRequest request, PkcsSignatureGenerator generator)
{
    byte[] pkcs10 = request.CreateSigningRequest(generator);
    StringBuilder builder = new StringBuilder();

    builder.AppendLine("-----BEGIN CERTIFICATE REQUEST-----");
                
    string base64 = Convert.ToBase64String(pkcs10);
                
    int offset = 0;
    const int LineLength = 64;
                
    while (offset < base64.Length)
    {
        int lineEnd = Math.Min(offset + LineLength, base64.Length);
        builder.AppendLine(base64.Substring(offset, lineEnd - offset));
        offset = lineEnd;
     }
                
     builder.AppendLine("-----END CERTIFICATE REQUEST-----");
     return builder.ToString();
}

CreateSigningRequest(X509SignatureGenerator)

Creates an ASN.1 DER-encoded PKCS#10 CertificationRequest representing the current state of the current object using the provided signature generator.

public:
 cli::array <System::Byte> ^ CreateSigningRequest(System::Security::Cryptography::X509Certificates::X509SignatureGenerator ^ signatureGenerator);
public byte[] CreateSigningRequest (System.Security.Cryptography.X509Certificates.X509SignatureGenerator signatureGenerator);
member this.CreateSigningRequest : System.Security.Cryptography.X509Certificates.X509SignatureGenerator -> byte[]
Public Function CreateSigningRequest (signatureGenerator As X509SignatureGenerator) As Byte()

Parameters

signatureGenerator
X509SignatureGenerator

The signature generator with which to sign the request.

Returns

Byte[]

A DER-encoded certificate signing request.

Exceptions

signatureGenerator is null.

Applies to