x509

How do I do TLS with BouncyCastle?

前提是你 提交于 2019-11-27 04:03:25
问题 Does anybody know about examples of TLS with BouncyCastle? I was surprised by the lack of them on Internet. If there are really none, let's collect them as answers. 回答1: This is a very basic example, with server-only authentication and self-signed cert. The code is based on BC 1.49, mostly leightweight API: ServerSocket serverSocket = new ServerSocket(SERVER_PORT); final KeyPair keyPair = ... final Certificate bcCert = new Certificate(new org.spongycastle.asn1.x509.Certificate[] { new

validating X.509 certificate on linux

旧城冷巷雨未停 提交于 2019-11-27 03:35:18
问题 I have just started working with X.509 certificates. Can any one tell me how to go about validating a certificate on linux? The use case is that my app had downloaded a certificate in a previous session and I have to check if it is still valid (i.e., not expired or revoked since it was stored) before starting a new session. I understand a full sample will not be possible here, but any pointers will be useful. EDIT: Further investigation revealed another utility called Network Security

Validate X.509 certificate against CA in Java

你说的曾经没有我的故事 提交于 2019-11-27 00:38:28
问题 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

How can I configure WCF to use x509 certificates over the internet?

佐手、 提交于 2019-11-26 23:56:55
问题 I need to use an x509 certificate to get secure message level authentication from a rich client via the internet to a secure WCF Web Service. Specifically, I am looking for a working step-by-step guide to setup, configuration, coding, and deployment, including creating a 'dev' certificate, installing it, and obtaining a 'real' certificate for production. 回答1: The following steps are a guide to get you started: 1) Firstly, you need a Root Authority to generate your client and server

Generating RSA keys in PKCS#1 format in Java

折月煮酒 提交于 2019-11-26 22:16:10
When I generate an RSA key pair using the Java API, the public key is encoded in the X.509 format and the private key is encoded in the PKCS#8 format. I'm looking to encode both as PKCS#1. Is this possible? I've spent a considerable amount of time going through the Java docs but haven't found a solution. The result is the same when I use the Java and the Bouncy Castle providers. Here is a snippet of the code: KeyPairGenerator keygen = KeyPairGenerator.getInstance("RSA","BC"); keygen.initialize(1024); KeyPair pair = keygen.generateKeyPair(); PrivateKey priv = pair.getPrivate(); PublicKey pub =

How to read a RSA public key in PEM + PKCS#1 format

不羁岁月 提交于 2019-11-26 19:50:36
问题 I have a RSA public key in PEM format + PKCS#1(I guess): -----BEGIN RSA PUBLIC KEY----- MIGJAoGBAJNrHWRFgWLqgzSmLBq2G89exgi/Jk1NWhbFB9gHc9MLORmP3BOCJS9k onzT/+Dk1hdZf00JGgZeuJGoXK9PX3CIKQKRQRHpi5e1vmOCrmHN5VMOxGO4d+zn JDEbNHODZR4HzsSdpQ9SGMSx7raJJedEIbr0IP6DgnWgiA7R1mUdAgMBAAE= -----END RSA PUBLIC KEY----- I want to get the SHA1 digest of its ASN1 encoded version in Python. The first step should be to read this key, but I failed to do it in PyCrypto: >> from Crypto.PublicKey import RSA >> RSA

Programmatically Create X509 Certificate using OpenSSL

一世执手 提交于 2019-11-26 19:25:47
I have a C/C++ application and I need to create a X509 pem certificate containing both a public and private key. The certificate can be self signed, or unsigned, doesn't matter. I want to do this inside an app, not from command line. What OpenSSL functions will do this for me? Any sample code is a bonus! Martin v. Löwis You'll need to familiarize yourself with the terminology and mechanisms first. An X.509 certificate , by definition, does not include a private key. Instead, it is a CA-signed version of the public key (along with any attributes the CA puts into the signature). The PEM format

Extract public/private key from PKCS12 file for later use in SSH-PK-Authentication

北城以北 提交于 2019-11-26 19:14:39
I want to extract the public and private key from my PKCS#12 file for later use in SSH-Public-Key-Authentication. Right now, I'm generating keys via ssh-keygen which I put into .ssh/authorized_key , respective somewhere on the client-side. In future, I want to use the keys from a PKCS#12 container, so I've to extract the public-key first from PKCS#12 and then put them into the .ssh/authorized_keys -file. Is there any chance to get this working via openssl? Are the keys in PKCS#12 compatible for ssh-public-key authentication? Nilesh You can use following commands to extract public/private key

CryptographicException 'Keyset does not exist', but only through WCF

╄→尐↘猪︶ㄣ 提交于 2019-11-26 18:13:26
I have some code that makes a call to a third party web service that is secured using X.509 certification. If I call the code directly (using a unit test) it works without any problems. When deployed, this code will be called via a WCF Service. I have added a second unit test that calls the WCF Service, however this fails with a CryptographicException , message "Keyset does not exist" when I call a method on the third party web service. I presume that this is because my WCF Service will be attempting to call the third party web service using a different user to myself. Can anyone shed any

Generating RSA keys in PKCS#1 format in Java

ぐ巨炮叔叔 提交于 2019-11-26 17:27:46
问题 When I generate an RSA key pair using the Java API, the public key is encoded in the X.509 format and the private key is encoded in the PKCS#8 format. I'm looking to encode both as PKCS#1. Is this possible? I've spent a considerable amount of time going through the Java docs but haven't found a solution. The result is the same when I use the Java and the Bouncy Castle providers. Here is a snippet of the code: KeyPairGenerator keygen = KeyPairGenerator.getInstance("RSA","BC"); keygen