Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
146153 | Jul 23,2019 11:03 AM UTC | Aug 7,2019 12:03 PM UTC | WinForms | 5 |
![]() |
Tags: PDF |
var certificate = new X509Certificate2(data, @"0123456789");
var certificatPdf = new PdfCertificate(certificate);
pdfFactory.Sign(signature.FieldName, certificatPdf, signature.FullName...
AsymmetricCipherKeyPair KeyPair = (AsymmetricCipherKeyPair)pmr.ReadObject();
public PdfCertificate(X509Certificate2 x509Certificate2);
n my case there is still a problem, because reading the private key file using Org.BouncyCastle.OpenSsl.PemReader I get InvalidCastException at the line 34:
AsymmetricCipherKeyPair KeyPair = (AsymmetricCipherKeyPair)pmr.ReadObject();
in my case, ReadObject returns an object of type Org.BouncyCastle.Crypto.Parameters.RsaPrivateCrtKeyParameters. We have managed to create a similiar workaround for ourselves, but it still feels wrong parsing and serializing the certificates over and over and we do it for a certificate chain with certificate authorities, which is being noticed on mobile platforms.
|
The sample which we have provided in the previous update is works fine in our end. Could you please share the certificate and private key (PEM format) used in your end. It will helpful for us to provide the precise solution on this.
|
Also when you say that you support only .pfx files, why is there this PdfCertificate constructor:
public PdfCertificate(X509Certificate2 x509Certificate2);
|
This constructor is used to get the certificate from certificate store. If you want to get certificate from store, you can use this overload.
Note: In certificate store, the loaded certificate should have a private key. |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.