1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| openssl genrsa -idea -out server.key 2048
Generating RSA private key, 2048 bit long modulus ................................................................................ ..................................................+++ .............................+++ e is 65537 (0x10001) Enter pass phrase for server.key: 1234 Verifying - Enter pass phrase for server.key: 1234
ll total 4 -rw-r--r-- 1 root root 1747 Jan 11 19:02 server.key
openssl req -days 36500 -x509 -sha256 -nodes -newkey rsa:2048 -keyout server.key -out server.crt
req --> 用于创建新的证书 new --> 表示创建的是新证书 x509 --> 表示定义证书的格式为标准格式 key --> 表示调用的私钥文件信息 out --> 表示输出证书文件信息 days --> 表示证书的有效期
Generating a 2048 bit RSA private key ..................+++ ............................................................+++ writing new private key to 'server,key' ----- You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. -----
Country Name (2 letter code) [XX]:CN
State or Province Name (full name) []:shanghai
Locality Name (eg, city) [Default City]:shanghai
Organization Name (eg, company) [Default Company Ltd]:oldboy
Organizational Unit Name (eg, section) []:oldboy
Common Name (eg, your name or your server's hostname) []:test.xxx.com # 邮箱 Email Address []:123@qq.com # 查看证书文件 -rw-r--r-- 1 root root 1411 Jan 11 19:08 server.crt -rw-r--r-- 1 root root 1704 Jan 11 19:08 server.key
|