I need to generate a certificate starting from the base64
string value of a PEM encoded CSR and a CA root certificate.
The CA certificate is generated using openssl
from the command line.
Given that CertificateRequest api from .NET does not provide a .FromPemBase64String()
method, it is basically impossible to use it in my case. I have tried to find a solution using BouncyCastle library but most of the solutions I have found generate a CSR on the fly while I actually need it to be parsed from a string.
Currently my solution is to:
- store the CSR to a file (
test.csr
) - programmatically run the following command:
openssl x509 -req -in test.csr -CA ca.crt -CAkey ca.key -passin pass:"password123" -CAcreateserial -out test.crt -days 730 -sha256
Everything works fine but it would be great if I can find a programmatically way to do the same (including generating the CA on the fly so I don't have to add the files to the project).
Does anyone have any suggestions?
I am currently using .NET6