x509

How to extract the domain name out of an X509Certificate object during SslStream.AuthenticateAsClient? (.NET4)

核能气质少年 提交于 2019-12-04 01:13:17
I have a RemoteCertificateValidationCallback function called by SslStream.AuthenticateAsClient, which is passed an X509Certificate object. I'd like to extract the name from that certificate, such that had I passed that string into AuthenticateAsClient, it would have passed. (Assuming no other issues.) (Note: The Subject property contains the domain name, but it's inside a "CN=..., S=..." etc formatted string.) See also: How to extract CN from X509Certificate in Java? (Asks a similar question for Java, but I can't find similar classes for .NET mentioned in those answers.) (Followup to Eugene's

Converting a SSL Cert to a .pem format

杀马特。学长 韩版系。学妹 提交于 2019-12-03 22:28:16
Hi I am a little new to all this openSSL and PEM stuf, so I thought I would ask you people here. I have a certificate in text(X509) format like this for example Certificate: Data: Version: 3 (0x2) Serial Number: 1f:19:f6:de:35:dd:63:a1:42:91:8a:d5:2c:c0:ab:12 Signature Algorithm: PKCS #1 SHA-1 With RSA Encryption Issuer: "CN=Thawte SGC CA,O=Thawte Consulting (Pty) Ltd.,C=ZA" Validity: Not Before: Fri Dec 18 00:00:00 2009 Not After : Sun Dec 18 23:59:59 2011 Subject: "CN=mail.google.com,O=Google Inc,L=Mountain View,ST=Californ ia,C=US" ............................................ ..............

C# Support for RSA SHA 256 signing for individual XML elements

冷暖自知 提交于 2019-12-03 22:14:20
问题 I have encountered a blocker with the .NET Framework version 4.5 to do with signing of XML with digital signatures. My problem is based around the need to sign individual XML elements with X.509 certificate with the RSA SHA-256 algorithm. I have read many .NET posts on this topic and it appears that there is a solution originally developed in the CLR Security project RSAPKCS1SHA256SignatureDescription.cs class. RSAPKCS1SHA256SignatureDescription has of course since been incorporated into the

Validate if RSA key matches X.509 certificate in Java

核能气质少年 提交于 2019-12-03 20:45:55
I have a RSA Key and a X.509 Certificate which I use for SSL connections. The key and certificate are stored in files in PEM format (generated by OpenSSL) and used in an Apache HTTP server environment. Is there an easy way to validate if the key matches the certificate using only Java code (without executing the openssl binary and parsing the output), for example by using Java security and/or Bouncycastle library methods? The following code compares the SHA-1 over the modulus within the public and private key. The modulus should be unique for each pair (unless you key pair generation mechanism

WCF Service Unable to Access Personal Certificate Store Unless Service Account is Logged In

感情迁移 提交于 2019-12-03 17:11:42
I created a WCF service that has a method which makes a call to a SOAP web service over the internet. In order to make a call to the SOAP web service, it requires that an X.509 certificate be sent with the HttpWebRequest. The X.509 certificates are loaded in the Personal and Trusted Certificate store of the account which the service is running under. When the service account is logged into the server, everything works just fine. However, when the service account is not physically logged onto the server, it has problems loading up the X.509 certificate and fails authentication when trying to

Verifying the domain of a certificate in OpenSSL

限于喜欢 提交于 2019-12-03 16:07:33
I need to verify the domain of an X509 certificate using C-land OpenSSL. My understanding is that the library doesn't do this for me, and that I have to implement roughly the following algorithm: If the dnsName field of the subjectAlternativeName extension is present, set name to that value. Otherwise, set name to the CN field of the subject. Compare name against the requested hostname, allowing each asterisk to match [A-Za-z0-9_]+, but not 'dot' (.). It seems to me that there should be plenty of code kicking around to do this, but I haven't found any. Can anyone find an example of this? Or

How to disable constraint check (Netscape cert type) in Java6?

偶尔善良 提交于 2019-12-03 14:41:29
问题 I am trying to build a custom HTTPS Server in Java (6) using the built in class com.sun.net.httpserver.HttpsServer. It works fine until I require client authentication. At that point it fails with the following exception in the SSL debug on the server. sun.security.validator.ValidatorException: Netscape cert type does not permit use for SSL client I am using certificates issued by our internal CA which is used for all applications internal to us. I checked the certificate details and found

X.509 RSA Encryption/Decryption iOS

喜欢而已 提交于 2019-12-03 13:26:58
问题 I need to implement encryption / decryption using a X.509 RSA public/private key pair. So far, I have something which I think will work for encryption, but I have no way of decrypting to check. Everything I try has issues reading the private key. Generating the key pairs (returns a .der and a .pem ) openssl req -x509 -out public_key.der -outform der -new -newkey rsa:1024 -keyout private_key.pem -days 3650 Encryption (Not sure if this works, but looks like it does) + (NSData *) RSAEncryptData:

Decoding an ASN.1 DER OCTET STRING with OpenSSL

大憨熊 提交于 2019-12-03 12:50:38
Using the OpenSSL API, I have extracted a custom extension from a X.509v3 certificate with: X509_EXTENSION* ex = X509_get_ext(x509, 4); The X509_EXTENSION object contains a value (ex->value) that is an ASN.1 OCTET STRING. The OCTET STRING contains a DER encoded UTF-8 string. I'm trying to decode the OCTET STRING to get the plain UTF-8 string. I have tried a few things, such as: ASN1_STRING_to_UTF8(&buf, ex->value); and M_ASN1_OCTET_STRING_print(bio, ex->value); int len = BIO_read(bio, buf, buf_size); buf[len] = '\0'; These both give me the DER encoded string. How do I get the plain UTF-8

How to programmatically create an X.509 certificate in .NET?

 ̄綄美尐妖づ 提交于 2019-12-03 09:49:29
问题 I'd like to create a new X.509 certificate in .NET, that meet the hash algorithm and key length requirements that I set. This will be a self-signed certificate. Creating a new certificate may create a new key, or perhaps I'd like to import an existing private key that I have in byte[] form. Does anyone know how to do it? 回答1: Maybe this post can be helpful. I use this code in our test environment to create self signed certificates. Best 回答2: One of the options is to use PKIBlackbox package of