public void AnomClientPdfDoubleSignSync() { DsspClient dsspClient = new DsspClient("https://www.e-contract.be/dss-ws/dss"); Document d = new Document("application/pdf", File.OpenRead("SignedDouble.pdf")); SecurityInfo si = dsspClient.Verify(d); Assert.AreEqual(2, si.Signatures.Count, "Signature Count"); //Validate signature 1 Assert.AreEqual("SERIALNUMBER=83121034221, GIVENNAME=Iryna, SURNAME=Brouckaert, CN=Iryna Brouckaert (Signature), C=BE", si.Signatures[1].SignerSubject, "Signature 2: SignerSubject (DSS notation)"); Assert.AreEqual("SERIALNUMBER=83121034221, G=Iryna, SN=Brouckaert, CN=Iryna Brouckaert (Signature), C=BE", si.Signatures[1].Signer.Subject, "Signature 2: Signer.Subject (Windows notation)"); Assert.AreEqual(new DateTime(2014, 9, 23, 20, 53, 18, DateTimeKind.Local), si.Signatures[1].SigningTime, "Signature 2: SigningTime"); Assert.AreEqual("Ik verklaar dat de inhoud van dit document nauwkeurig en volledig is", si.Signatures[1].SignerRole, "Signature 2: SignerRole"); Assert.AreEqual("Denderleeuw", si.Signatures[1].SignatureProductionPlace, "Signature 1: SignatureProductionPlace"); //Validate signature 2 Assert.AreEqual("SERIALNUMBER=79021802145, GIVENNAME=Bryan Eduard, SURNAME=Brouckaert, CN=Bryan Brouckaert (Signature), C=BE", si.Signatures[0].SignerSubject, "Signature 1: SignerSubject (DSS notation)"); Assert.AreEqual("SERIALNUMBER=79021802145, G=Bryan Eduard, SN=Brouckaert, CN=Bryan Brouckaert (Signature), C=BE", si.Signatures[0].Signer.Subject, "Signature 1: Signer.Subject (Windows notation)"); Assert.AreEqual(new DateTime(2014, 9, 23, 20, 11, 34, DateTimeKind.Local), si.Signatures[0].SigningTime, "Signature 1: SigningTime"); Assert.AreEqual("Zaakvoerder", si.Signatures[0].SignerRole, "Signature 1: SignerRole"); Assert.AreEqual("Denderleeuw", si.Signatures[0].SignatureProductionPlace, "Signature 1: SignatureProductionPlace"); //Validate timestamp validity Assert.AreEqual(new DateTime(2019, 1, 23, 11, 0, 0, DateTimeKind.Utc), si.TimeStampValidity, "TimeStampValidity"); }
public void TestMethod1() { for (int i = 0; i < 100000; i++) { var pxy = new DsspClient("https://www.e-contract.be/dss-ws/dss"); } }
public void SignAsyncNoLangInvisibleNoProps() { DsspClient dsspClient = new DsspClient("https://www.e-contract.be/dss-ws/dss"); dsspClient.Application.X509.Certificate = new X509Certificate2("certificate.p12", ""); DsspSession s; using (Stream i = File.OpenRead("Blank.pdf")) { Document id = new Document("application/pdf", i); s = dsspClient.UploadDocument(id); } String signResponse = emulateBrowser( s.GeneratePendingRequest("http://localhost/dssp"), "View Document"); NameIdentifierType signer = s.ValidateSignResponse(signResponse); Assert.AreEqual("SERIALNUMBER=79021802145, GIVENNAME=Bryan Eduard, SURNAME=Brouckaert, CN=Bryan Brouckaert (Signature), C=BE", signer.Value); Document od = dsspClient.DownloadDocument(s); using (Stream o = File.OpenWrite("Output.pdf")) { od.Content.CopyTo(o); } od.Content.Seek(0, SeekOrigin.Current); Verify(od, null, null); }
//[Test] public void VerifyPdfDoubleSignSync() { DsspClient dsspClient = new DsspClient("https://www.e-contract.be/dss-ws/dss"); Document d = new Document("application/pdf", File.OpenRead("SignedDouble.pdf")); SecurityInfo si = dsspClient.Verify(d); Assert.AreEqual(2, si.Signatures.Count, "Signature Count"); //Validate signature 1 Assert.AreEqual("SERIALNUMBER=83121034221, GIVENNAME=Iryna, SURNAME=Brouckaert, CN=Iryna Brouckaert (Signature), C=BE", si.Signatures[1].SignerSubject, "Signature 2: SignerSubject (DSS notation)"); Assert.AreEqual("SERIALNUMBER=83121034221, G=Iryna, SN=Brouckaert, CN=Iryna Brouckaert (Signature), C=BE", si.Signatures[1].Signer.Subject, "Signature 2: Signer.Subject (Windows notation)"); Assert.AreEqual(new DateTime(2014, 9, 23, 20, 53, 18, DateTimeKind.Local), si.Signatures[1].SigningTime, "Signature 2: SigningTime"); Assert.AreEqual("Ik verklaar dat de inhoud van dit document nauwkeurig en volledig is", si.Signatures[1].SignerRole, "Signature 2: SignerRole"); Assert.AreEqual("Denderleeuw", si.Signatures[1].SignatureProductionPlace, "Signature 1: SignatureProductionPlace"); //Validate signature 2 Assert.AreEqual("SERIALNUMBER=79021802145, GIVENNAME=Bryan Eduard, SURNAME=Brouckaert, CN=Bryan Brouckaert (Signature), C=BE", si.Signatures[0].SignerSubject, "Signature 1: SignerSubject (DSS notation)"); Assert.AreEqual("SERIALNUMBER=79021802145, G=Bryan Eduard, SN=Brouckaert, CN=Bryan Brouckaert (Signature), C=BE", si.Signatures[0].Signer.Subject, "Signature 1: Signer.Subject (Windows notation)"); Assert.AreEqual(new DateTime(2014, 9, 23, 20, 11, 34, DateTimeKind.Local), si.Signatures[0].SigningTime, "Signature 1: SigningTime"); Assert.AreEqual("Zaakvoerder", si.Signatures[0].SignerRole, "Signature 1: SignerRole"); Assert.AreEqual("Denderleeuw", si.Signatures[0].SignatureProductionPlace, "Signature 1: SignatureProductionPlace"); //Validate timestamp validity Assert.AreEqual(new DateTime(2019, 1, 23, 11, 0, 0, DateTimeKind.Utc), si.TimeStampValidity, "TimeStampValidity"); }
public void Sign2StepInvisibleProps() { DsspClient dsspClient = new DsspClient("https://www.e-contract.be/dss-ws/dss"); dsspClient.Application.X509.Certificate = new X509Certificate2("certificate.p12", ""); dsspClient.SignerChain = new X509Certificate2[] { Signer }; Dssp2StepSession s; SignatureRequestProperties props = new SignatureRequestProperties() { SignerRole = "Witness", SignatureProductionPlace = "Iddergem" }; using (Stream i = File.OpenRead("Blank.pdf")) { Document id = new Document("application/pdf", i); s = dsspClient.UploadDocumentFor2Step(id, props); } s.Sign(); Document od = dsspClient.DownloadDocument(s); using (Stream o = File.OpenWrite("Output.pdf")) { od.Content.CopyTo(o); } od.Content.Seek(0, SeekOrigin.Current); Verify(od, "Witness", "Iddergem"); }
public void SealVisibleProps() { DsspClient dsspClient = new DsspClient("https://www.e-contract.be/dss-ws/dss"); dsspClient.Application.X509.Certificate = new X509Certificate2("certificate.p12", ""); Document od; SignatureRequestProperties props = new SignatureRequestProperties() { SignerRole = "Gard", SignatureProductionPlace = "Iddergem", VisibleSignature = new ImageVisibleSignature() { Page = 1, X = 100, Y = 100 } }; using (Stream i = File.OpenRead("Blank.pdf")) { Document id = new Document("application/pdf", i); od = dsspClient.Seal(id, props); } using (Stream o = File.OpenWrite("Output.pdf")) { od.Content.CopyTo(o); } od.Content.Seek(0, SeekOrigin.Current); VerifySeal(od, "Gard", "Iddergem"); }
protected void Page_Load(object sender, EventArgs e) { Document document = new Document(); document.MimeType = "application/pdf"; document.Content = File.OpenRead(Path.Combine(HostingEnvironment.ApplicationPhysicalPath, @"App_Data\dssp-specs.pdf")); DsspClient dsspClient = new DsspClient("https://www.e-contract.be/dss-ws/dss"); dsspClient.ApplicationName = Settings.Default.AppName; dsspClient.ApplicationPassword = Settings.Default.AppPwd; DsspSession dsspSession = dsspClient.UploadDocument(document); Session["dsspSession"] = dsspSession; VisibleSignatureProperties visibleSignature = null; if (Session["Visible"] == "Photo") { visibleSignature = new ImageVisibleSignature() { Page = (int) Session["Page"], X = (int) Session["X"], Y = (int) Session["Y"] }; } else if (Session["Visible"] == "Photo and Signer Info") { visibleSignature = new ImageVisibleSignature() { Page = (int)Session["Page"], X = (int)Session["X"], Y = (int)Session["Y"], ValueUri = "urn:be:e-contract:dssp:1.0:vs:si:eid-photo:signer-info", CustomText = (string)Session["CustomText"] }; } // verify whether DsspSession is serializable BinaryFormatter binaryFormatter = new BinaryFormatter(); MemoryStream memoryStream = new MemoryStream(); binaryFormatter.Serialize(memoryStream, dsspSession); memoryStream.Seek(0, SeekOrigin.Begin); dsspSession = (DsspSession) binaryFormatter.Deserialize(memoryStream); Authorization authorization = new Authorization(); //authorization.AddAuthorizedCardNumber("591937284531"); //authorization.AddAuthorizedSubjectName("SERIALNUMBER=79102520991, GIVENNAME=Frank Henri, SURNAME=Cornelis, CN=Frank Cornelis (Signature), C=BE"); //authorization.AddNonAuthorizedSubjectName("SERIALNUMBER=79102520991, GIVENNAME=Frank Henri, SURNAME=Cornelis, CN=Frank Cornelis (Signature), C=BE"); this.PendingRequest.Value = dsspSession.GeneratePendingRequest( new Uri(Request.Url, ResolveUrl("~/Signed.aspx")), Settings.Default.Language, new SignatureRequestProperties() { SignerRole = (string)Session["Role"], SignatureProductionPlace = (string)Session["Location"], VisibleSignature = visibleSignature }, authorization ); }
public void SignAsyncAuthZViaCardNr() { DsspClient dsspClient = new DsspClient("https://www.e-contract.be/dss-ws/dss"); dsspClient.Application.X509.Certificate = new X509Certificate2("certificate.p12", ""); DsspSession s; using (Stream i = File.OpenRead("Blank.pdf")) { Document id = new Document("application/pdf", i); s = dsspClient.UploadDocument(id); } String correct = "591591588049"; Authorization authz = Authorization.AllowDssSignIfMatchCardNumber(correct); String signResponse = emulateBrowser( s.GeneratePendingRequest(new Uri("http://localhost/dssp"), "EN", authz), "View Document"); try { using (Stream i = File.OpenRead("Blank.pdf")) { Document id = new Document("application/pdf", i); s = dsspClient.UploadDocument(id); } authz = Authorization.DenyDssSignIfMatchCardNumber(correct); signResponse = emulateBrowser( s.GeneratePendingRequest(new Uri("http://localhost/dssp"), "EN", authz), "View Document"); Assert.Fail("should fail with wrong"); } catch (InvalidOperationException) { } try { using (Stream i = File.OpenRead("Blank.pdf")) { Document id = new Document("application/pdf", i); s = dsspClient.UploadDocument(id); } authz = Authorization.AllowDssSignIfMatchCardNumber("591-3291070-59"); signResponse = emulateBrowser( s.GeneratePendingRequest(new Uri("http://localhost/dssp"), "EN", authz), "View Document"); Assert.Fail("should fail with wrong"); } catch (InvalidOperationException) { } }
public void AnomClientPdfNoSignSync() { //Use alternative ways to specify URL DsspClient dsspClient = new DsspClient(new EndpointAddress("https://www.e-contract.be/dss-ws/dss")); Document d = new Document("application/pdf", File.OpenRead("Blank.pdf")); SecurityInfo si = dsspClient.Verify(d); //Validate lack of signature Assert.IsNull(si, "Verify must return null"); }
public void VerifyPdfNoSignSync() { //Use alternative ways to specify URL DsspClient dsspClient = new DsspClient(new EndpointAddress("https://www.e-contract.be/dss-ws/dss")); Document d = new Document("application/pdf", File.OpenRead("Blank.pdf")); SecurityInfo si = dsspClient.Verify(d); //Validate lack of signature Assert.IsNull(si, "Verify must return null"); }
public void SignAsyncAuthZViaSubject() { DsspClient dsspClient = new DsspClient("https://www.e-contract.be/dss-ws/dss"); dsspClient.Application.X509.Certificate = new X509Certificate2("certificate.p12", ""); DsspSession s; using (Stream i = File.OpenRead("Blank.pdf")) { Document id = new Document("application/pdf", i); s = dsspClient.UploadDocument(id); } String correct = "SERIALNUMBER=79021802145, GIVENNAME=Bryan Eduard, SURNAME=Brouckaert, CN=Bryan Brouckaert (Signature), C=BE"; Authorization authz = Authorization.AllowDssSignIfMatchSubject(correct); String signResponse = emulateBrowser( s.GeneratePendingRequest(new Uri("http://localhost/dssp"), "EN", authz), "View Document"); try { using (Stream i = File.OpenRead("Blank.pdf")) { Document id = new Document("application/pdf", i); s = dsspClient.UploadDocument(id); } authz = Authorization.DenyDssSignIfMatchSubject(correct); signResponse = emulateBrowser( s.GeneratePendingRequest(new Uri("http://localhost/dssp"), "EN", authz), "View Document"); Assert.Fail("should fail with wrong"); } catch (InvalidOperationException) { } try { using (Stream i = File.OpenRead("Blank.pdf")) { Document id = new Document("application/pdf", i); s = dsspClient.UploadDocument(id); } authz = Authorization.AllowDssSignIfMatchSubject("SERIALNUMBER=00000000000, GIVENNAME=Bryan Eduard, SURNAME=Brouckaert, CN=Bryan Brouckaert (Signature), C=BE"); signResponse = emulateBrowser( s.GeneratePendingRequest(new Uri("http://localhost/dssp"), "EN", authz), "View Document"); Assert.Fail("should fail with wrong"); } catch (InvalidOperationException) { } }
public void SignAsyncNLVisiblePropsMultiText() { DsspClient dsspClient = new DsspClient("https://www.e-contract.be/dss-ws/dss"); dsspClient.Application.UT.Name = "egelke"; dsspClient.Application.UT.Password = "******"; DsspSession s; using (Stream i = File.OpenRead("Blank.pdf")) { Document id = new Document("application/pdf", i); s = dsspClient.UploadDocument(id); } SignatureRequestProperties props = new SignatureRequestProperties() { SignerRole = "Developer", SignatureProductionPlace = "Oost-Vlaanderen", VisibleSignature = new ImageVisibleSignature() { CustomText = "Custom", CustomText2 = "Custom2", CustomText3 = "Custom3", CustomText4 = "Custom4", CustomText5 = "Custom5", ValueUri = "urn:be:e-contract:dssp:1.0:vs:si:eid-photo:signer-info", Page = 1, X = 500, Y = 700 } }; String signResponse = emulateBrowser( s.GeneratePendingRequest(new Uri("http://localhost/dssp"), "NL", props), "Document bekijken"); NameIdentifierType signer = s.ValidateSignResponse(signResponse); Assert.AreEqual("SERIALNUMBER=79021802145, GIVENNAME=Bryan Eduard, SURNAME=Brouckaert, CN=Bryan Brouckaert (Signature), C=BE", signer.Value); Document od = dsspClient.DownloadDocument(s); using (Stream o = File.OpenWrite("Output.pdf")) { od.Content.CopyTo(o); } od.Content.Seek(0, SeekOrigin.Current); Verify(od, "Developer", "Oost-Vlaanderen"); }
private void Verify(Document d, String role, String location) { DsspClient dsspClient = new DsspClient("https://www.e-contract.be/dss-ws/dss"); SecurityInfo si = dsspClient.Verify(d); Assert.AreEqual(1, si.Signatures.Count, "Signature Count"); //Validate signature 1 Assert.AreEqual("SERIALNUMBER=79021802145, GIVENNAME=Bryan Eduard, SURNAME=Brouckaert, CN=Bryan Brouckaert (Signature), C=BE", si.Signatures[0].SignerSubject, "Signature 1: SignerSubject (DSS notation)"); Assert.AreEqual("SERIALNUMBER=79021802145, G=Bryan Eduard, SN=Brouckaert, CN=Bryan Brouckaert (Signature), C=BE", si.Signatures[0].Signer.Subject, "Signature 1: Signer.Subject (Windows notation)"); Assert.IsTrue(si.Signatures[0].SigningTime > (DateTime.Now - TimeSpan.FromMinutes(5)) && si.Signatures[0].SigningTime < (DateTime.Now + TimeSpan.FromMinutes(5)), "Signature 1: SigningTime"); Assert.AreEqual(role, si.Signatures[0].SignerRole, "Signature 1: SignerRole"); Assert.AreEqual(location, si.Signatures[0].SignatureProductionPlace, "Signature 1: SignatureProductionPlace"); //Validate timestamp validity Assert.AreEqual(new DateTime(2020, 8, 18, 19, 11, 6, DateTimeKind.Utc), si.TimeStampValidity, "TimeStampValidity"); }
public void VerifyXmlSingleSignSync() { DsspClient dsspClient = new DsspClient("https://www.e-contract.be/dss-ws/dss"); Document d = new Document("text/xml", File.OpenRead("Signed.xml")); SecurityInfo si = dsspClient.Verify(d); Assert.AreEqual(1, si.Signatures.Count, "Signature Count"); //Validate signature 1 Assert.AreEqual("SERIALNUMBER=79021802145, GIVENNAME=Bryan Eduard, SURNAME=Brouckaert, CN=Bryan Brouckaert (Signature), C=BE", si.Signatures[0].SignerSubject, "Signature 1: SignerSubject (DSS notation)"); Assert.AreEqual("SERIALNUMBER=79021802145, G=Bryan Eduard, SN=Brouckaert, CN=Bryan Brouckaert (Signature), C=BE", si.Signatures[0].Signer.Subject, "Signature 1: Signer.Subject (Windows notation)"); Assert.AreEqual(new DateTime(2014, 9, 23, 21, 26, 01, DateTimeKind.Local), si.Signatures[0].SigningTime, "Signature 1: SigningTime"); Assert.IsNull(si.Signatures[0].SignerRole, "Signature 1: SignerRole"); Assert.IsNull(si.Signatures[0].SignatureProductionPlace, "Signature 1: SignatureProductionPlace"); //Validate timestamp validity Assert.AreEqual(new DateTime(2019, 1, 23, 11, 0, 0, DateTimeKind.Utc), si.TimeStampValidity, "TimeStampValidity"); }
public void VerifyPdfSingleSignASync() { DsspClient dsspClient = new DsspClient("https://www.e-contract.be/dss-ws/dss"); Document d = new Document("application/pdf", File.OpenRead("Signed.pdf")); SecurityInfo si = dsspClient.VerifyAsync(d).ConfigureAwait(false).GetAwaiter().GetResult(); Assert.AreEqual(1, si.Signatures.Count, "Signature Count"); //Validate signature 1 Assert.AreEqual("SERIALNUMBER=79021802145, GIVENNAME=Bryan Eduard, SURNAME=Brouckaert, CN=Bryan Brouckaert (Signature), C=BE", si.Signatures[0].SignerSubject, "Signature 1: SignerSubject (DSS notation)"); Assert.AreEqual("SERIALNUMBER=79021802145, G=Bryan Eduard, SN=Brouckaert, CN=Bryan Brouckaert (Signature), C=BE", si.Signatures[0].Signer.Subject, "Signature 1: Signer.Subject (Windows notation)"); Assert.AreEqual(new DateTime(2014, 9, 23, 20, 11, 34, DateTimeKind.Local), si.Signatures[0].SigningTime, "Signature 1: SigningTime"); Assert.AreEqual("Zaakvoerder", si.Signatures[0].SignerRole, "Signature 1: SignerRole"); Assert.AreEqual("Denderleeuw", si.Signatures[0].SignatureProductionPlace, "Signature 1: SignatureProductionPlace"); //Validate timestamp validity Assert.AreEqual(new DateTime(2019, 1, 23, 11, 0, 0, DateTimeKind.Utc), si.TimeStampValidity, "TimeStampValidity"); }
public void VerifyPdfSingleSignSync() { //Specify signature type, which isn't used here DsspClient dsspClient = new DsspClient(new EndpointAddress("https://www.e-contract.be/dss-ws/dss"), "urn:be:e-contract:dssp:signature:pades-baseline"); Document d = new Document("application/pdf", File.OpenRead("Signed.pdf")); SecurityInfo si = dsspClient.Verify(d); Assert.AreEqual(1, si.Signatures.Count, "Signature Count"); //Validate signature 1 Assert.AreEqual("SERIALNUMBER=79021802145, GIVENNAME=Bryan Eduard, SURNAME=Brouckaert, CN=Bryan Brouckaert (Signature), C=BE", si.Signatures[0].SignerSubject, "Signature 1: SignerSubject (DSS notation)"); Assert.AreEqual("SERIALNUMBER=79021802145, G=Bryan Eduard, SN=Brouckaert, CN=Bryan Brouckaert (Signature), C=BE", si.Signatures[0].Signer.Subject, "Signature 1: Signer.Subject (Windows notation)"); Assert.AreEqual(new DateTime(2014, 9, 23, 20, 11, 34, DateTimeKind.Local), si.Signatures[0].SigningTime, "Signature 1: SigningTime"); Assert.AreEqual("Zaakvoerder", si.Signatures[0].SignerRole, "Signature 1: SignerRole"); Assert.AreEqual("Denderleeuw", si.Signatures[0].SignatureProductionPlace, "Signature 1: SignatureProductionPlace"); //Validate timestamp validity Assert.AreEqual(new DateTime(2019, 1, 23, 11, 0, 0, DateTimeKind.Utc), si.TimeStampValidity, "TimeStampValidity"); }
public void SealInvisibleNoProps() { DsspClient dsspClient = new DsspClient("https://www.e-contract.be/dss-ws/dss"); dsspClient.Application.X509.Certificate = new X509Certificate2("certificate.p12", ""); Document od; using (Stream i = File.OpenRead("Blank.pdf")) { Document id = new Document("application/pdf", i); od = dsspClient.Seal(id); } using (Stream o = File.OpenWrite("Output.pdf")) { od.Content.CopyTo(o); } od.Content.Seek(0, SeekOrigin.Current); VerifySeal(od, null, null); }
private void VerifySeal(Document d, String role, String location) { DsspClient dsspClient = new DsspClient("https://www.e-contract.be/dss-ws/dss"); dsspClient.Application.UT.Name = "egelke"; dsspClient.Application.UT.Password = "******"; SecurityInfo si = dsspClient.Verify(d); Assert.AreEqual(1, si.Signatures.Count, "Signature Count"); //Validate signature 1 Assert.AreEqual("SERIALNUMBER=123456, CN=Test Signing Key, C=BE", si.Signatures[0].SignerSubject, "Signature 1: SignerSubject (DSS notation)"); Assert.AreEqual("SERIALNUMBER=123456, CN=Test Signing Key, C=BE", si.Signatures[0].Signer.Subject, "Signature 1: Signer.Subject (Windows notation)"); Assert.IsTrue(si.Signatures[0].SigningTime > (DateTime.Now - TimeSpan.FromMinutes(5)) && si.Signatures[0].SigningTime < (DateTime.Now + TimeSpan.FromMinutes(5)), "Signature 1: SigningTime"); Assert.AreEqual(role, si.Signatures[0].SignerRole, "Signature 1: SignerRole"); Assert.AreEqual(location, si.Signatures[0].SignatureProductionPlace, "Signature 1: SignatureProductionPlace"); //Validate timestamp validity Assert.AreEqual(new DateTime(2025, 12, 31, 22, 00, 01, DateTimeKind.Utc), si.TimeStampValidity, "TimeStampValidity"); }
public void Sign2StepInvisiblePropsAndProvidedChain() { DsspClient dsspClient = new DsspClient("https://www.e-contract.be/dss-ws/dss"); dsspClient.Application.X509.Certificate = new X509Certificate2("certificate.p12", ""); X509Chain chain = new X509Chain(); chain.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck; chain.ChainPolicy.VerificationFlags = X509VerificationFlags.AllFlags; Assert.IsTrue(chain.Build(Signer), "Failed to build the chain"); dsspClient.SignerChain = chain.ChainElements .OfType <X509ChainElement>() .Select(e => e.Certificate) .ToArray(); Dssp2StepSession s; SignatureRequestProperties props = new SignatureRequestProperties() { SignerRole = "Witness", SignatureProductionPlace = "Iddergem" }; using (Stream i = File.OpenRead("Blank.pdf")) { Document id = new Document("application/pdf", i); s = dsspClient.UploadDocumentFor2Step(id, props); } s.Sign(); Document od = dsspClient.DownloadDocument(s); using (Stream o = File.OpenWrite("Output.pdf")) { od.Content.CopyTo(o); } od.Content.Seek(0, SeekOrigin.Current); Verify(od, "Witness", "Iddergem"); }
public void Sign2StepInvisibleNoProps() { DsspClient dsspClient = new DsspClient("https://www.e-contract.be/dss-ws/dss"); dsspClient.Application.X509.Certificate = new X509Certificate2("certificate.p12", ""); dsspClient.Signer = Signer; Dssp2StepSession s; using (Stream i = File.OpenRead("Blank.pdf")) { Document id = new Document("application/pdf", i); s = dsspClient.UploadDocumentFor2Step(id); } s.Sign(); Document od = dsspClient.DownloadDocument(s); using (Stream o = File.OpenWrite("Output.pdf")) { od.Content.CopyTo(o); } od.Content.Seek(0, SeekOrigin.Current); Verify(od, null, null); }
public void AnomClientXmlSingleSignSync() { DsspClient dsspClient = new DsspClient("https://www.e-contract.be/dss-ws/dss"); Document d = new Document("text/xml", File.OpenRead("Signed.xml")); SecurityInfo si = dsspClient.Verify(d); Assert.AreEqual(1, si.Signatures.Count, "Signature Count"); //Validate signature 1 Assert.AreEqual("SERIALNUMBER=79021802145, GIVENNAME=Bryan Eduard, SURNAME=Brouckaert, CN=Bryan Brouckaert (Signature), C=BE", si.Signatures[0].SignerSubject, "Signature 1: SignerSubject (DSS notation)"); Assert.AreEqual("SERIALNUMBER=79021802145, G=Bryan Eduard, SN=Brouckaert, CN=Bryan Brouckaert (Signature), C=BE", si.Signatures[0].Signer.Subject, "Signature 1: Signer.Subject (Windows notation)"); Assert.AreEqual(new DateTime(2014, 9, 23, 21, 26, 01, DateTimeKind.Local), si.Signatures[0].SigningTime, "Signature 1: SigningTime"); Assert.IsNull(si.Signatures[0].SignerRole, "Signature 1: SignerRole"); Assert.IsNull(si.Signatures[0].SignatureProductionPlace, "Signature 1: SignatureProductionPlace"); //Validate timestamp validity Assert.AreEqual(new DateTime(2019, 1, 23, 11, 0, 0, DateTimeKind.Utc), si.TimeStampValidity, "TimeStampValidity"); }
public void AnomClientPdfSingleSignSync() { //Specify signature type, which isn't used here DsspClient dsspClient = new DsspClient(new EndpointAddress("https://www.e-contract.be/dss-ws/dss"), "urn:be:e-contract:dssp:signature:pades-baseline"); Document d = new Document("application/pdf", File.OpenRead("Signed.pdf")); SecurityInfo si = dsspClient.Verify(d); Assert.AreEqual(1, si.Signatures.Count, "Signature Count"); //Validate signature 1 Assert.AreEqual("SERIALNUMBER=79021802145, GIVENNAME=Bryan Eduard, SURNAME=Brouckaert, CN=Bryan Brouckaert (Signature), C=BE", si.Signatures[0].SignerSubject, "Signature 1: SignerSubject (DSS notation)"); Assert.AreEqual("SERIALNUMBER=79021802145, G=Bryan Eduard, SN=Brouckaert, CN=Bryan Brouckaert (Signature), C=BE", si.Signatures[0].Signer.Subject, "Signature 1: Signer.Subject (Windows notation)"); Assert.AreEqual(new DateTime(2014, 9, 23, 20, 11, 34, DateTimeKind.Local), si.Signatures[0].SigningTime, "Signature 1: SigningTime"); Assert.AreEqual("Zaakvoerder", si.Signatures[0].SignerRole, "Signature 1: SignerRole"); Assert.AreEqual("Denderleeuw", si.Signatures[0].SignatureProductionPlace, "Signature 1: SignatureProductionPlace"); //Validate timestamp validity Assert.AreEqual(new DateTime(2019, 1, 23, 11, 0, 0, DateTimeKind.Utc), si.TimeStampValidity, "TimeStampValidity"); }
public void AuthClientPdfSingleSignSync() { DsspClient dsspClient = new DsspClient("https://www.e-contract.be/dss-ws/dss"); dsspClient.ApplicationName = "egelke"; dsspClient.ApplicationPassword = "******"; Document d = new Document("application/pdf", File.OpenRead("Signed.pdf")); SecurityInfo si = dsspClient.Verify(d); Assert.AreEqual(1, si.Signatures.Count, "Signature Count"); //Validate signature 1 Assert.AreEqual("SERIALNUMBER=79021802145, GIVENNAME=Bryan Eduard, SURNAME=Brouckaert, CN=Bryan Brouckaert (Signature), C=BE", si.Signatures[0].SignerSubject, "Signature 1: SignerSubject (DSS notation)"); Assert.AreEqual("SERIALNUMBER=79021802145, G=Bryan Eduard, SN=Brouckaert, CN=Bryan Brouckaert (Signature), C=BE", si.Signatures[0].Signer.Subject, "Signature 1: Signer.Subject (Windows notation)"); Assert.AreEqual(new DateTime(2014, 9, 23, 20, 11, 34, DateTimeKind.Local), si.Signatures[0].SigningTime, "Signature 1: SigningTime"); Assert.AreEqual("Zaakvoerder", si.Signatures[0].SignerRole, "Signature 1: SignerRole"); Assert.AreEqual("Denderleeuw", si.Signatures[0].SignatureProductionPlace, "Signature 1: SignatureProductionPlace"); //Validate timestamp validity Assert.AreEqual(new DateTime(2019, 1, 23, 11, 0, 0, DateTimeKind.Utc), si.TimeStampValidity, "TimeStampValidity"); }