x509certificate

X509Certificate.CreateFromCertFile - the specified network password is not correct

纵然是瞬间 提交于 2019-11-28 07:25:30
I have a .NET application that I want to use as a client to call an SSL SOAP web service. I have been supplied with a valid client certificate called foo.pfx . There is a password on the certificate itself. I've located the certificate at the following location: C:\certs\foo.pfx To call the web service, I need to attach the client certificate. Here's the code: public X509Certificate GetCertificateFromDisk(){ try{ string certPath = ConfigurationManager.AppSettings["MyCertPath"].ToString(); //this evaluates to "c:\\certs\\foo.pfx". So far so good. X509Certificate myCert = X509Certificate

How can I use certificate authentication with HttpsURLConnection?

会有一股神秘感。 提交于 2019-11-28 06:33:47
I'm trying to connect to an HTTPS URL, but I need to use client authentication with a certificate placed on my system by third party software. I haven't the slightest idea how I'm supposed to either find or use it and all I have to go on is C# sample code, which differs significantly with all the Java answers I've found about this. (for instance, the KeyStore needs some sort of password apparently?) This is the C# sample code I have System.Security.Cryptography.X509Certificates.X509CertificateCollection SSC_Certs = new System.Security.Cryptography.X509Certificates.X509CertificateCollection();

X509Certificate - Keyset does not exist

▼魔方 西西 提交于 2019-11-28 06:18:05
I have a WinForms application that consumes a WCF, and pass as a parameter to a function a certificate: mySvcClient.SendDocument(cert.Export(X509ContentType.SerializedCert, "password")); ... In WCF service , I recreated the certificate from the array of bytes: public void SendDocument (byte[] binaryCert) { X509Certificate2 cert = new X509Certificate2(binaryCert, "password"); ... But when using the certificate to sign a xml, I got the error "Keyset does not exist": if (cert.HasPrivateKey) // WORKS!!! { signedXml.SigningKey = cert.PrivateKey; // THROW "keyset does not exist" EXCEPTION ... In my

Validate X.509 certificate against CA in Java

荒凉一梦 提交于 2019-11-28 05:05:24
Lets say I have something like this (client side code): TrustManager[] trustAllCerts = new TrustManager[]{ new X509TrustManager() { @Override public java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; } @Override public void checkClientTrusted( java.security.cert.X509Certificate[] certs, String authType) { } @Override public void checkServerTrusted( java.security.cert.X509Certificate[] certs, String authType) { } } }; SSLContext sslc = SSLContext.getInstance("TLS"); sslc.init(null, trustAllCerts, null); SocketFactory sf = sslc.getSocketFactory(); SSLSocket s = (SSLSocket)

Associate a private key with the X509Certificate2 class in .net

橙三吉。 提交于 2019-11-28 05:02:30
I'm working on some code that creates a X509certificate and a public/private key pair. The public key is added to the certificate and it is sent to an CA which signs it. The returned certificate is then accessed through the System.Security.Cryptography.X509Certificates.X509Certificate2 class. Now I want to use this certificate to initiate a secure connection with other clients. Therefore I use the SslStream class. To start the SSL Handshake I use this method: server.AssociatedSslStream.AuthenticateAsServer( MyCertificate, // Client Certificate true, // Require Certificate from connecting Peer

CryptographicException was unhandled: System cannot find the specified file

a 夏天 提交于 2019-11-28 03:33:08
I am trying to embrace the mysteries of SSL communication and have found a great tutorial on this site . I was trying to test my own certificate. Using Visual Studio 2012, I simply added an existing file (my certificate in .pfx format) and then changed the "certificate" and "password" settings in app.config. However, when trying to run it, I got an error: CryptographicException was unhandled: System cannot find the specified file Then, I tried the same in my Web Service. There I got some more details about the error: System.Security.Cryptography.CryptographicException: System cannot find

Azure Hosted Service Bus : “The X.509 certificate CN=servicebus.windows.net is not in the trusted people store.”

♀尐吖头ヾ 提交于 2019-11-28 02:08:39
Using Azure SDK 2.3 on my vs2013 development VM I can consume Service Bus queues hosted in Azure painlessly. However, on Windows Server 2008 R2 Standard SP1, it looks like Windows can not trust the involved certificates and an exception is thrown. The line that throws : // Send the message await queueclient.SendAsync(message); Exception message : The X.509 certificate CN=servicebus.windows.net is not in the trusted people store. The X.509 certificate CN=servicebus.windows.net chain building failed. The certificate that was used has a trust chain that cannot be verified. Replace the certificate

Generating self-signed certificate without external libraries

对着背影说爱祢 提交于 2019-11-28 02:00:05
问题 I'm curious to know if there's a simplish way to create a self-signed certificate comparable to the below New-SelfSignedCertificate command (other providers are OK too, for instance). I want to use only the .NET libraries without P/Invoke or external libraries such as Bouncy Castle or without calling PowerShell from the application. New-SelfSignedCertificate -DnsName $certificateName -CertStoreLocation $certificateStore -KeyExportPolicy Exportable -Provider "Microsoft Enhanced RSA and AES

Use PEM Encoded CA Cert on filesystem directly for HTTPS request?

非 Y 不嫁゛ 提交于 2019-11-28 00:35:25
This is similar to Import PEM into Java Key Store . But the question's answers use OpenSSL for conversions and tools to import them into key stores on the file system. I'm trying to use a well formed X509 certificate as a trust anchor: static String CA_FILE = "ca-rsa-cert.pem"; public static void main(String[] args) throws Exception { KeyStore ks = KeyStore.getInstance("JKS"); ks.load(new FileInputStream(CA_FILE), null); TrustManagerFactory tmf = TrustManagerFactory .getInstance(TrustManagerFactory.getDefaultAlgorithm()); tmf.init(ks); SSLContext context = SSLContext.getInstance("TLS");

How to get PEM encoded X509 certificate as C++ string using openssl?

非 Y 不嫁゛ 提交于 2019-11-28 00:30:55
I have a openssl X509 structure with a self signed certificate. I need to get a PEM formatted C++ string from this structure. What are the openssl APIs that I need to use to achieve this? I tried following the example program at https://www.codeblog.org/gonzui/markup/openssl-0.9.8a/demos/x509/mkcert.c . This program shows a way to write the certificate in PEM format to a file. I can read the contents of this file into a C++ string if there is no other way to do it. look at the source of the openssl x509 command and see how it does the operation to read a DER encoded file and writes a PEM one -