pem

Convert .PEM certificate to .PFX Programatically using OpenSSL

I've got a .PEM file that I want to convert to a PKCS12 file (PFX) and I know I can easily accomplish this using the following openssl command: Create a PKCS#12 file: openssl pkcs12 -export -in file.pem -out file.p12 -name "My Certificate" Which is great, but I'd like to do this programmatically using openssl calls. Unfortunately...

How do I encrypt with an RSA private key read from a PEM file using the Go programming language?

How do I do the equivalent of the following C++ code in go? RSA *key = PEM_read_RSAPrivateKey(f, NULL, NULL, NULL); std::vector<CK_BYTE> out(128); RSA_private_encrypt(in.size(), &in[0], &out[0], key, RSA_PKCS1_PADDING) I've looked at the Go rsa package. It looks like EncryptPKCS1v15() may be the equivalent of RSA_private_encrypt(). ...

Keep SSL keyfile open in Python

I'm using Python's ssl library with an encrypted keyfile. However every time I wrap a socket, I'm prompted for the passphrase. Enter PEM pass phrase: How can I give the passphrase just once, and have Python hold the decrypted key open for the lifetime of the process? I'm very interested in the canonical openssl command line or C equi...

Write x509 certificate into PEM formatted string in java?

Is there some high level way to write an X509Certificate into a PEM formatted string? Currently I'm doing x509cert.encode() to write it into a DER formatted string, then base 64 encoding it and appending the header and footer to create a PEM string, but it seems bad. Especially since I have to throw in line breaks too. ...

How to know whether .pem file is correct or not

Hi There, I have created a .pem file to be used for Production push notification, and uploaded in server. But when sending push notification, it is giving error like this. $fp = stream_socket_client('ssl://gateway.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT, $ctx); not working, return failed. what is this error, h...

How would I go about converting a hexadecimal representation of a private key to a OpenSSL supported format(PEM/DER/?)

The title basically says it all. I have a hexadecimal string representing a private key, and for me to be able to use it with OpenSSL, I need to be able to convert it to some format supported by OpenSSL, be it PEM or whatever. I know that one can read a PEM formatted key and print it out in a format like this: Private-Key: (102...

Convert a PKCS#8 private key to PEM in java

Hello everyone I'm trying to convert a PKCS#8 private key that I generate in my java program to a PEM encoded file. Security.addProvider(new BouncyCastleProvider()); SecureRandom rand = new SecureRandom(); JDKKeyPairGenerator.RSA keyPairGen = new JDKKeyPairGenerator.RSA(); keyPairGen.initialize(2048, rand); KeyPair keyPair = ke...

Convert RSA public key, from XML to PEM (PHP)

How convert RSA public key, from XML to PEM (PHP)? ...

Formatting RSA keys for OpenSSL in Java

Background RSA key generation with OpenSSL on Linux using the command, openssl genrsa -out mykey.pem 1024 created the following: "-----BEGIN RSA PRIVATE KEY----- MIICXQIBAAKBgQChs9Fepy5FgeL0gNJ8GHcKRHsYnM2Kkw19zwydDQNyh2hrHWV2 B11wpLFp8d0imcl2Wjb0oV/AxOhb3unQgNzs66LVuXJwS8icp3oIJZtExs6tkxzE s5mnU68wMeCYtJqHIZOmNblVWvpJMLNAwAVi3o...

Trouble connecting to SSL-encrypted web service with PHP

I got two certificate files from the provider, one in a .cer-format and one in a .p7b-format. I then converted the p7b-certificate to a p12-certificate. With this certificate I'm able to connect to the wsdl from my browser. Then I proceeded to convert that certificate to .pem-format, using some instructions I found on this site. openssl...

iphone : revoke distribution certificate and push notifications

I have an iPhone app with push notifications enabled and it's working pretty well. But my mac mini just "died" and I realize I did forgot to backup my public / private keys :/ So I guess my only solution now is to create new certificates (both developer and distribution) so I can continue my work ... but what happens with my push notific...

Signing data with PEM key and password in PHP. How to do same thing in .NET?

Hello everyone, I've got this code written in PHP: $text = "some data to sign"; $password = "some password"; $file = "private.pem"; $fp = fopen($file, "r"); $private = fread($fp, filesize($file)); fclose($fp); $pkeyid = openssl_get_privatekey($private, $password); openssl_sign($text, $signature, $pkeyid); $signature = base64_encode($s...

How to decrypt a string on OpenSSL that was previously encrypted via Crypto++?

EDIT: I found out that the keys aren't the problem like I said in the comments. I can use them without any issues to encrypt and decrypt data on OpenSSL. But I need to decrypt a string on OpenSSL that was previously encrypted via Crypto++ and that's not working. I'll post additional details later. Hi, I have encrypted a string using a...