public X509Certificate2Collection(System.Security.Cryptography.X509Certificates.X509Certificate2Collection certificates) { }
public void RemoveRange(System.Security.Cryptography.X509Certificates.X509Certificate2Collection certificates) { }
public void Decrypt(System.Security.Cryptography.X509Certificates.X509Certificate2Collection extraStore) { }
public void CheckSignature(System.Security.Cryptography.X509Certificates.X509Certificate2Collection extraStore, bool verifySignatureOnly) { }
public CmsRecipientCollection(System.Security.Cryptography.Pkcs.SubjectIdentifierType recipientIdentifierType, System.Security.Cryptography.X509Certificates.X509Certificate2Collection certificates) { }
public void Decrypt(System.Security.Cryptography.Pkcs.RecipientInfo recipientInfo, System.Security.Cryptography.X509Certificates.X509Certificate2Collection extraStore) { }
public bool OnSelectClientCertificate(IWebBrowser browserControl, IBrowser browser, bool isProxy, string host, int port, System.Security.Cryptography.X509Certificates.X509Certificate2Collection certificates, ISelectClientCertificateCallback callback) { callback.Dispose(); return(false); }
bool IRequestHandler.OnSelectClientCertificate(IWebBrowser browserControl, IBrowser browser, bool isProxy, string host, int port, System.Security.Cryptography.X509Certificates.X509Certificate2Collection certificates, ISelectClientCertificateCallback callback) { return(false); }
public static void Test() { System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12; // System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls13; System.Security.Cryptography.X509Certificates.X509Store store = new System.Security.Cryptography.X509Certificates.X509Store( System.Security.Cryptography.X509Certificates.StoreName.Root ); store.Open(System.Security.Cryptography.X509Certificates.OpenFlags.ReadWrite); // Retrieve the certificate System.Security.Cryptography.X509Certificates.X509Certificate2Collection certs = store.Certificates.Find( System.Security.Cryptography.X509Certificates.X509FindType.FindBySubjectName , "SSL-SERVER" , false ); // There is no result when vaildOnly = true. if (certs.Count == 0) { // return; // cert = new System.Security.Cryptography.X509Certificates.X509Certificate2(); // foreach (System.Security.Cryptography.X509Certificates.X509Certificate2 certificate in store.Certificates) { cert = certificate; break; } string[] altNames = SelfSignedCertificate.SelfSigned.GetAlternativeNames(new string[0]); byte[] pfx = SelfSignedCertificate.SelfSigned.CreateSelfSignedCertificate(altNames, ""); cert = new System.Security.Cryptography.X509Certificates.X509Certificate2(pfx, "", System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.Exportable // | System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.EphemeralKeySet // Error ! ); } else { cert = certs[0]; } store.Close(); // Close the storage area. System.Net.Sockets.TcpListener server = new System.Net.Sockets.TcpListener(System.Net.IPAddress.Any, 900); System.Threading.Thread thread_server = new System.Threading.Thread( new System.Threading.ParameterizedThreadStart(RunServer) ); thread_server.Start(server); // client code using (System.Net.Sockets.TcpClient tc = new System.Net.Sockets.TcpClient()) { string connectTo = "127.0.0.1"; connectTo = "localhost"; connectTo = "example.int"; connectTo = System.Environment.MachineName; tc.Connect(connectTo, 900); System.Net.Security.SslStream stream = new System.Net.Security.SslStream(tc.GetStream(), false , new System.Net.Security.RemoteCertificateValidationCallback(ValidateServerCertificate) ) { ReadTimeout = IOTimeout, WriteTimeout = IOTimeout }; // stream.AuthenticateAsClient(connectTo, null, true); stream.AuthenticateAsClient(connectTo, certs, System.Security.Authentication.SslProtocols.Tls12, true); // stream.AuthenticateAsClient(connectTo, certs, System.Security.Authentication.SslProtocols.Tls13, true); // This is where you read and send data while (true) { string echo = System.Console.ReadLine(); byte[] buff = System.Text.Encoding.UTF8.GetBytes(echo + "<EOF>"); stream.Write(buff, 0, buff.Length); stream.Flush(); //tc.GetStream().Write(buff, 0, buff.Length); //tc.GetStream().Flush(); } // tc.Close(); } }
private static bool TryFindCertificatesInStore(string thumbprint, System.Security.Cryptography.X509Certificates.StoreLocation location, out System.Security.Cryptography.X509Certificates.X509Certificate2Collection certificates) { System.Security.Cryptography.X509Certificates.X509Store store = new System.Security.Cryptography.X509Certificates.X509Store(System.Security.Cryptography.X509Certificates.StoreName.My, location); store.Open(System.Security.Cryptography.X509Certificates.OpenFlags.ReadOnly); certificates = store.Certificates.Find(System.Security.Cryptography.X509Certificates.X509FindType.FindByThumbprint, thumbprint, false); store.Close(); return(certificates.Count > 0); }
public static void Run() { // ExStart:1 // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_SecuritySignatures(); File.Copy(dataDir + "blank.pdf", dataDir + "externalSignature1.pdf", true); using (FileStream fs = new FileStream(dataDir + "externalSignature1.pdf", FileMode.Open, FileAccess.ReadWrite)) { using (Document doc = new Document(fs)) { SignatureField field1 = new SignatureField(doc.Pages[1], new Rectangle(100, 400, 10, 10)); // Sign with certificate selection in the windows certificate store System.Security.Cryptography.X509Certificates.X509Store store = new System.Security.Cryptography.X509Certificates.X509Store(System.Security.Cryptography.X509Certificates.StoreLocation.CurrentUser); store.Open(System.Security.Cryptography.X509Certificates.OpenFlags.ReadOnly); // Manually chose the certificate in the store System.Security.Cryptography.X509Certificates.X509Certificate2Collection sel = System.Security.Cryptography.X509Certificates.X509Certificate2UI.SelectFromCollection(store.Certificates, null, null, System.Security.Cryptography.X509Certificates.X509SelectionFlag.SingleSelection); Aspose.Pdf.Forms.ExternalSignature externalSignature = new Aspose.Pdf.Forms.ExternalSignature(sel[0]) { Authority = "Me", Reason = "Reason", ContactInfo = "Contact" }; field1.PartialName = "sig1"; doc.Form.Add(field1, 1); field1.Sign(externalSignature); doc.Save(); } } using (PdfFileSignature pdfSign = new PdfFileSignature(new Document(dataDir + "externalSignature1.pdf"))) { IList <string> sigNames = pdfSign.GetSignNames(); for (int index = 0; index <= sigNames.Count - 1; index++) { if (!pdfSign.VerifySigned(sigNames[index]) || !pdfSign.VerifySignature(sigNames[index])) { throw new ApplicationException("Not verified"); } } } // ExEnd:1 }
public bool VerifySignatureForSignerInfo(System.Security.Cryptography.Pkcs.SignerInfo signerInfo, out System.Security.Cryptography.X509Certificates.X509Certificate2 signerCertificate, System.Security.Cryptography.X509Certificates.X509Certificate2Collection extraCandidates = null) { throw null; }
public X509CertificateEndpointIdentity(System.Security.Cryptography.X509Certificates.X509Certificate2 primaryCertificate, System.Security.Cryptography.X509Certificates.X509Certificate2Collection supportingCertificates) { }
public bool VerifySignatureForData(System.ReadOnlySpan <byte> data, out System.Security.Cryptography.X509Certificates.X509Certificate2 signerCertificate, System.Security.Cryptography.X509Certificates.X509Certificate2Collection extraCandidates = null) { throw null; }
public static System.Security.Cryptography.X509Certificates.X509Certificate2Collection SelectFromCollection(System.Security.Cryptography.X509Certificates.X509Certificate2Collection certificates, string title, string message, System.Security.Cryptography.X509Certificates.X509SelectionFlag selectionFlag, System.IntPtr hwndParent) { throw null; }
public bool VerifySignatureForHash(System.ReadOnlySpan <byte> hash, System.Security.Cryptography.HashAlgorithmName hashAlgorithm, out System.Security.Cryptography.X509Certificates.X509Certificate2 signerCertificate, System.Security.Cryptography.X509Certificates.X509Certificate2Collection extraCandidates = null) { throw null; }
public static void Run() { // ExStart:1 // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_SecuritySignatures(); Document doc = new Document(dataDir + "blank.pdf"); using (Facades.PdfFileSignature pdfSign = new Facades.PdfFileSignature()) { pdfSign.BindPdf(doc); // Sign with certificate selection in the windows certificate store System.Security.Cryptography.X509Certificates.X509Store store = new System.Security.Cryptography.X509Certificates.X509Store(System.Security.Cryptography.X509Certificates.StoreLocation.CurrentUser); store.Open(System.Security.Cryptography.X509Certificates.OpenFlags.ReadOnly); // Manually chose the certificate in the store System.Security.Cryptography.X509Certificates.X509Certificate2Collection sel = System.Security.Cryptography.X509Certificates.X509Certificate2UI.SelectFromCollection(store.Certificates, null, null, System.Security.Cryptography.X509Certificates.X509SelectionFlag.SingleSelection); Aspose.Pdf.Forms.ExternalSignature externalSignature = new Aspose.Pdf.Forms.ExternalSignature(sel[0]); pdfSign.SignatureAppearance = dataDir + "demo.png"; pdfSign.Sign(1, "Reason", "Contact", "Location", true, new System.Drawing.Rectangle(100, 100, 200, 200), externalSignature); pdfSign.Save(dataDir + "externalSignature2.pdf"); } using (Facades.PdfFileSignature pdfSign = new Facades.PdfFileSignature(new Document(dataDir + "externalSignature2.pdf"))) { IList <string> sigNames = pdfSign.GetSignNames(); for (int index = 0; index <= sigNames.Count - 1; index++) { if (!pdfSign.VerifySigned(sigNames[index]) || !pdfSign.VerifySignature(sigNames[index])) { throw new ApplicationException("Not verified"); } } } // ExEnd:1 }