ReadCertificate() public static method

Reads A Personal Information Exchange File.
public static ReadCertificate ( string pfxPath, string pfxPassword ) : PdfRpt.Core.Security.PfxData
pfxPath string Certificate file's path
pfxPassword string Certificate file's password
return PdfRpt.Core.Security.PfxData
        private void readCertificate()
        {
            var certs = PfxReader.ReadCertificate(SignatureData.CertificateFile.PfxPath, SignatureData.CertificateFile.PfxPassword);

            _asymmetricKeyParameter = certs.PublicKey;
            _chain = certs.X509PrivateKeys;
        }
Example #2
0
        private void setPublicKeyEncryption(List <int> permissionsList)
        {
            if (DocumentSecurity.EncryptionPreferences.EncryptionType != EncryptionType.PublicKeyEncryption)
            {
                return;
            }

            if (permissionsList.Count == 0)
            {
                permissionsList.Add(PdfWriter.AllowScreenReaders);
            }
            var certs = PfxReader.ReadCertificate(DocumentSecurity.EncryptionPreferences.PublicKeyEncryption.PfxPath, DocumentSecurity.EncryptionPreferences.PublicKeyEncryption.PfxPassword);

            PdfWriter.SetEncryption(
                certs: certs.X509PrivateKeys,
                permissions: permissionsList.ToArray(),
                encryptionType: PdfWriter.ENCRYPTION_AES_128);
        }
        private void signPublicKeyEncryption(Stream pdfStreamOutput)
        {
            if (DocumentSecurity.EncryptionPreferences.EncryptionType != EncryptionType.PublicKeyEncryption)
            {
                return;
            }

            var pfxData = PfxReader.ReadCertificate(DocumentSecurity.EncryptionPreferences.PublicKeyEncryption.PfxPath, DocumentSecurity.EncryptionPreferences.PublicKeyEncryption.PfxPassword);

            DocumentSecurity.DigitalSignature.CertificateFile.AppendSignature = true;

            new SignatureWriter
            {
                SignatureData = new Signature
                {
                    CertificateFile  = DocumentSecurity.DigitalSignature.CertificateFile,
                    SigningInfo      = DocumentSecurity.DigitalSignature.SigningInfo,
                    VisibleSignature = DocumentSecurity.DigitalSignature.VisibleSignature
                }
            }.SignPdf(pdfStreamOutput, pfxData);
        }