Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -499,38 +499,35 @@ The type of signing key represented by <paramref name="issuerCertificate" /> cou
<remarks>
<format type="text/markdown"><![CDATA[

## 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-----`.
## 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-----`.

```csharp
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;

```csharp
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();
}
```
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();
}
```

]]></format>
</remarks>
<exception cref="T:System.InvalidOperationException">The current object was created using a constructor that doesn't accept a signing key.</exception>
Expand Down Expand Up @@ -663,4 +660,4 @@ The type of signing key represented by <paramref name="issuerCertificate" /> cou
</Docs>
</Member>
</Members>
</Type>
</Type>