pkcs#12

PKCS#12 : DerInputStream.getLength() exception

纵饮孤独 提交于 2019-11-30 03:52:55
I generate a certificate using the keytool command: keytool -genkeypair -alias myRSAKey -keyalg RSA -keysize 1024 -keystore test.p12 -storepass test -storetype pkcs12 Then if I try to load it using java security API, after getting the file as a byte[] : KeyStore ks = KeyStore.getInstance("PKCS12"); try{ ks.load(new ByteArrayInputStream(data), "test".toCharArray()) } catch (Exception e){ ... } I get a DerInputStream.getLength(): lengthTag=127, too big exception. What is wrong? I had this problem and I've searched the depths of google and still couldn't find the answer. After some days battling

programmatically import .cer certificate into keystore

浪尽此生 提交于 2019-11-30 03:46:25
How can I import a .p12 certificate from the classpath into the java keystore? First I used the InstallCert https://code.google.com/p/java-use-examples/source/browse/trunk/src/com/aw/ad/util/InstallCert.java and did some changes so the server certificate will be imported into the keystore in the java install directory. This works fine but now I want to load a certificate from my classpath. EDIT: I just use a .cer certificate, see next answer Pali The answer: InputStream certIn = ClassLoader.class.getResourceAsStream("/package/myCert.cer"); final char sep = File.separatorChar; File dir = new

Now that SSLSocketFactory is deprecated on Android, what would be the best way to handle Client Certificate Authentication?

余生长醉 提交于 2019-11-30 00:23:20
I am working on an Android app that requires Client Certificate Authentication (with PKCS 12 files). Following the deprecation of all that's apache.http.* , we have started a pretty big work of refactoring on our network layer, and we have decided to go with OkHttp as a replacement, and so far I like that very much. However, I haven't found any other way to handle client certificate auth without using SSLSocketFactory , with OkHttp or anything else for that matter. So what would be the best course of action in this particular case? Is there another way with OkHttp to handle this sort of

aps_developer_identity.cer to p12 without having to export from Key Chain?

瘦欲@ 提交于 2019-11-29 19:55:00
I have a shed load of 'aps_developer_identity.cer' certificates exported from iPhone Developer portal. They were all created using the same Certificate Signing Request and (thus) the same private key. If I export just the private key from the Apple Key Chain is it then possible to take the private key and the 'aps_developer_identity.cer' and use openssl to create merged p12/pkcs#12 certificate that I can use on my (Windows) server. Just to be clear, I know how to get a merged p12 from the Key Chain by exporting both the private key and certificate together, but I want to remove all the extra

Creating a .p12 file

怎甘沉沦 提交于 2019-11-29 19:43:50
Using openssl , I've created a private key as follows: openssl genrsa -out myKey.pem Then, to generate the csr demanded by the CA, I've executed the following: openssl req -new -key myKey.pem -out cert.csr The CA responded with a certificate which I stored in a file named myCert.cer I'd now like to bundle the necessary components (private key, public key(?) and certificate) into a single .p12 . To do so I've run the following: openssl pkcs12 -export -out keyStore.p12 -inkey myKey.pem -in myCert.cer but I'm getting the following error message: No certificate matches private key How can I

This certificate has an invalid issuer keychain

ぃ、小莉子 提交于 2019-11-29 14:26:05
问题 I do have private key(my_ca.key) and public key(my_cert.crt) which is signed by DigiCert. Now I want to generate the SSL certificate (version 3) and sign it by my private key . Here is the way I tried to do that. But when I export into keychain (Mac OS X). I have been getting error like this " This certificate has an invalid issuer keychain ". No idea how to solve this. Here my_cert.crt is extended from DigiCert High Assurance CA-3 and that one extended from DigiCert High Assurance EV Root CA

How to make a valid p12 file to be correctly imported by SecPKCS12Import

我与影子孤独终老i 提交于 2019-11-29 12:43:48
问题 I've solved my previos problem of converting XML RSA private key to PEM file, but I run into another problem that I get null data when importing P12 private key. Following is my steps: Convert PEM file to P12 file openssl> pkcs12 -export -in rsa.pem -inkey rsa.pem -out rsa.p12 -nocerts Read P12 file to iOS project NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"MyPrivateKey" ofType:@"p12"]; NSData *p12data = [NSData dataWithContentsOfFile:path]; if (![self

How to create a digital certificate and export to .p12 file in PHP?

给你一囗甜甜゛ 提交于 2019-11-29 11:47:45
How to create a digital certificate and export to .p12 file in PHP? I want the .p12 file to have private key included. And also want to check whether the key pair is already issued (logged in database). I found a function called 'openssl_pkcs12_export_to_file' but don't know where to start. Seems that I need an X509 cert and a private key first. <?php error_reporting(-1); function dump($Var) { echo "<hr/><pre>"; var_dump($Var); echo "</pre><hr/>"; } function check_errors() { echo "<hr/><pre>"; $Count = 0; while (($e=openssl_error_string())!==false) { echo $e."<br>"; $Count++; } if ($Count==0)

Extracting client certificate & private key from .p12 file

泪湿孤枕 提交于 2019-11-29 07:57:12
Can anybody tell me how to use PKCS12 *d2i_PKCS12_fp(FILE *fp, PKCS12 **p12); int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert, STACK_OF(X509) **ca); any documenatation reference will also work. Without error-checking: FILE *p12_file; PKCS12 *p12_cert = NULL; EVP_PKEY *pkey; X509 *x509_cert; STACK_OF(X509) *additional_certs = NULL; p12_file = fopen("foo.p12", "rb"); d2i_PKCS12_fp(p12_file, &p12_cert); fclose(p12_file); PKCS12_parse(p12_cert, "password", &pkey, &x509_cert, &additional_certs); The private key is now in pkey , the certificate in x509_cert and any

Openssl convert .PEM containing only RSA Private Key to .PKCS12

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-28 23:21:53
Currently I have a .PEM file containing only a private key. I need to convert this file into a .PKCS12 file. Currently I'm trying to use openssl to achieve this and I'm running into some problems. The .PEM file I'm using is of the form: -----BEGIN RSA PRIVATE KEY----- Some key -----END RSA PRIVATE KEY----- I use the following Openssl command to attempt to convert this .PEM file into a .PKCS12: openssl pkcs12 -export -inkey file.pem -out file.p12 The console then hangs with the message: Loading 'screen' into random state -done What am Im doing wrong? Any help would be appriciated. beaudet I ran