Load RSA public key from file

Below is the relevant information from the link which Zaki provided. Generate a 2048-bit RSA private key $ openssl genrsa -out private_key.pem 2048 Convert private Key to PKCS#8 format (so Java can read it) $ openssl pkcs8 -topk8 -inform PEM -outform DER -in private_key.pem -out private_key.der -nocrypt Output public key portion in DER format (so … Read more

Replace Mcrypt with OpenSSL

Blowfish is the block cipher. It requires the data to be padded before encryption. OpenSSL uses PKCS#7 and mcrypt uses PKCS#5. Different padding algorythms for data. Minimal PKCS#5 padding length is 0, for PKCS#7 it’s 1 (wikipedia). Take a look at this example (i’ve manually padded input data for mcrypt_encrypt() in PKCS#7 style): <?php $key … Read more

Python Requests requests.exceptions.SSLError: [Errno 8] _ssl.c:504: EOF occurred in violation of protocol

Reposting this here for others from the requests issue page: Requests’ does not support doing this before version 1. Subsequent to version 1, you are expected to subclass the HTTPAdapter, like so: from requests.adapters import HTTPAdapter from requests.packages.urllib3.poolmanager import PoolManager import ssl class MyAdapter(HTTPAdapter): def init_poolmanager(self, connections, maxsize, block=False): self.poolmanager = PoolManager(num_pools=connections, maxsize=maxsize, block=block, ssl_version=ssl.PROTOCOL_TLSv1) … Read more

How to read .pem file to get private and public key

Try this class. package groovy; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.security.GeneralSecurityException; import java.security.InvalidKeyException; import java.security.KeyFactory; import java.security.NoSuchAlgorithmException; import java.security.PrivateKey; import java.security.PublicKey; import java.security.Signature; import java.security.SignatureException; import java.security.interfaces.RSAPrivateKey; import java.security.interfaces.RSAPublicKey; import java.security.spec.PKCS8EncodedKeySpec; import java.security.spec.X509EncodedKeySpec; import javax.crypto.Cipher; import org.apache.commons.codec.binary.Base64; public class RSA { private static String getKey(String filename) throws IOException { // Read … Read more

How can I generate a self-signed certificate with SubjectAltName using OpenSSL? [closed]

Can someone help me with the exact syntax? It’s a three-step process, and it involves modifying the openssl.cnf file. You might be able to do it with only command line options, but I don’t do it that way. Find your openssl.cnf file. It is likely located in /usr/lib/ssl/openssl.cnf: $ find /usr/lib -name openssl.cnf /usr/lib/openssl.cnf /usr/lib/openssh/openssl.cnf … Read more

OpenSSL and error in reading openssl.conf file

On Windows you can also set the environment property OPENSSL_CONF. For example from the commandline you can type: set OPENSSL_CONF=c:/libs/openssl-0.9.8k/openssl.cnf to validate it you can type: echo %OPENSSL_CONF% You can also set it as part of the computer’s environmental variables so all users and services have it available by default. See, for example, Environment variables … Read more