dotnet / dotnet/dotnet-api-docs

Add hint that Export might be required

Open
#12,374 1 comment 0 reactions 0 assignees View on GitHub
area-System.Security untriaged
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

### Type of issue

Typo

### Description

Hi, it would be nice to add a hint that the certificate that is loaded via "X509Certificate2.CreateFromPemFile()" cannot be used in some scenarios directly.
If you want the present it to your Kestrel server it is not valid, not allowing a client to connect (No Server Hello).
You would need to export/create it like so:

certificate = X509Certificate2.CreateFromPemFile(
certificatePath,
certificatePrivatePath);
certificate = new X509Certificate2(certificate.Export(X509ContentType.Pkcs12));

### Page URL

https://learn.microsoft.com/en-us/dotnet/api/system.security.cryptography.x509certificates.x509certificate2.createfrompemfile?view=net-10.0

### Content source URL

https://github.com/dotnet/dotnet-api-docs/blob/main/xml/System.Security.Cryptography.X509Certificates/X509Certificate2.xml

### Document Version Independent Id

dcb4e1f8-d29a-bf51-2d12-58d8c06cbf54

### Platform Id

d378ae0e-0999-c43e-e3c6-d63fa87b0002

### Article author

@dotnet-bot

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.