示例#1
0
 public virtual void OpenEncryptedDocWithWrongCertificateAndPrivateKey()
 {
     NUnit.Framework.Assert.That(() =>  {
         PdfReader reader = new PdfReader(sourceFolder + "encryptedWithCertificateAes128.pdf", new ReaderProperties
             ().SetPublicKeySecurityParams(GetPublicCertificate(sourceFolder + "wrong.cer"), CryptoUtil.ReadPrivateKeyFromPkcs12KeyStore
             (new FileStream(sourceFolder + "wrong.p12", FileMode.Open, FileAccess.Read), "demo", "password".ToCharArray
             ())));
         PdfDocument doc = new PdfDocument(reader);
         doc.Close();
     }
     , NUnit.Framework.Throws.InstanceOf<PdfException>().With.Message.EqualTo(PdfException.BadCertificateAndKey))
     ;
 }
示例#2
0
 /// <exception cref="System.IO.IOException"/>
 /// <exception cref="Java.Security.Cert.CertificateException"/>
 public virtual X509Certificate GetPublicCertificate(String path)
 {
     FileStream @is = new FileStream(path, FileMode.Open, FileAccess.Read);
     return CryptoUtil.ReadPublicCertificate(@is);
 }