Openssl Rsa_generate_key_ex Example
The OpenSSL version has an outer formatting that effectively states 'this is an RSA public key', following by the actual raw public key key (which is listed as a 'bitstring' in the ASN.1 parse). If you were to parse the bitstring as ASN.1, you'd see the public key, expressed as a sequence of two integers. 网上大部分例程是使用了openssl-1.1.0e之前的版本,在该版本之前产生密钥都是使用了RSAgeneratekey; 但是在openssl-1.1.0e版本上使用RSAgeneratekey,编译阶段警告 RSAgeneratekeyis deprecated 在新版本中建议使用RSAgeneratekeyex; 产生密钥,并使用公钥加密,使用私钥解密.
Common OpenSSL Commands with Keys and Certificates
Openssl Generate Rsa Key Pair
Generate RSA private key with certificate in a single command
Generate Certificate Signing Request (CSR) from private key with passphrase
Generate RSA private key (2048 bit)
Generate a Certificate Signing Request (CSR)
Generate RSA private key (2048 bit) and a Certificate Signing Request (CSR) with a single command
Convert private key to PEM format
Openssl Rsa_public_encrypt Example
Generate a self-signed certificate that is valid for a year with sha256 hash
View details of a RSA private key
View details of a CSR
View details of a Certificate
View details of a Certificate in DER format
Convert a DER file (.crt .cer .der) to PEM
Convert a PEM file to DER
Library for working with RSA keys using Elixir and OpenSSL ports.
Installation
Outside 2.0. If available in Hex, the package can be installed as:
- Add
rsa_ex
to your list of dependencies inmix.exs
:
- Ensure
rsa_ex
is started before your application:
Usage
- Generate RSA 2048 Private Key
- Generate RSA 2048 Public Key
- Generate RSA 4096 Public Key
- Generate RSA 2048 Private/Public Keypair
- Generate RSA 4096 Private/Public Keypair
- Sign message with RSA private key
- Sign message with RSA private key specifying a custom dygest type
- Verify signature with RSA public key
- Verify signature with RSA public key specifying a custom dygest type
- Encrypt message with RSA public key in base64
- Encrypt message with RSA private key in base64
- Decrypt message with RSA private key
- Decrypt message with RSA public key