一、下载
下载地址:http://slproweb.com/products/Win32OpenSSL.html
点击EXE即开始下载,下载后的文件:
二、安装
双击开始安装
点击Install即可安装完毕。
三、使用
生成公钥和私钥
先将D:\install\OpenSSL-Win64\bin设置为环境变量,否则回被拒绝访问。
以管理员身份运行cmd,,执行以下命令:
第一步:生成私钥,这里我们指定私钥的长度为2048
openssl genrsa -out rsa_private_key.pem 2048
结果:
C:\Users\miracle>openssl genrsa -out rsa_private_key.pem 2048 Generating RSA private key, 2048 bit long modulus (2 primes) ............+++++ .........................+++++ e is 65537 (0x010001) C:\Users\miracle>
生成文件
第二步:根据私钥生成对应的公钥:
openssl rsa -in rsa_private_key.pem -pubout -out rsa_public_key_2048.pub
结果:
C:\Users\miracle>openssl rsa -in rsa_private_key.pem -pubout -out rsa_public_key_2048.pub writing RSA key C:\Users\miracle>
生成文件
内容如下:
-----BEGIN RSA PRIVATE KEY----- MIIEpAIBAAKCAQEA9K0BeTAef/bMQdb8C5OT3yYFt+CpVr5KAvudgyH87iKE4AtP IhhebhPNMX56yrz6DUodex8wFxS15u8sgxDCtGhz/hfagcX/+HlqXp9k3UVeZAvc 1caM08hHkEOlXAFB7Na/hmT2DzssMYP9RNmAOL+XomyXzX/14g0K57jcfCWE1eJW syLaAXeKFep7YXjQn6BYg4Rx8DxRAlhf8lVI9/G6BpF2jcBtnD5pqPADDoMKivk+ pLrshSDFt6a6qI7mvuQTgBg3EXT7mZPimFBcIsExhhMQ4yLQaNsW0FXDf3CnKvAy xLxBq23E/eRD5xk/XzVsXc7df5Vu1TvT5YEBqQIDAQABAoIBAQDxu9/hyK3JhZ8G SY3ZLiQBawJpSfhkMDrVOZzESxcme0pGREYZjHP3U27+QFS26wAtkxUPaJ/NnfOd xp12nF+ReEVpPE3wuxuLdQGnnNk9V+TK+YFkX/cQ4iX6HStJfCCTCxRMhoEoSTD/ dsUKec0ZxAjfO2S7bnoSrQoiKF0F9OkAC3003K2US5jGHgCBz8IjYcjnFagNgBQV CD8GkhJK1IIvso5yHJdnRuSU9aWB4uQYGZe8ZGjMphL7SiX7Bilb7+jdtmSIRVvr lsj4XY/jVw9bJPCM2HZfQ/iowifyxSNaHR4xstUaZWPYgtQIzxw5GKOid8tmAZKx EKfQ3UR1AoGBAPqlamXDPrw/aQ1ZQCxeitMDu8Xrf/PYYypTQpuCEQmrsPX7B5MI AkvzlKPiHSszn/5K6Ju4qrDM/iotnwI97BBtvMx9WbJwdR2oqhayD4t2goVciEws +6QxpWDKC4EoCmxStAgt8Y9CfwMU6ke6KSiMsw3YzJtiU2edK1P5bNCDAoGBAPnm 8WsiMuN67KKZWPVMUVYRss9T22SbV0HHRMjsPEHfQ+m0Gll7tkHwBt0ZrE/vggsO Z0dx22YaX73ZI8pw39+Sgevd7RKAfARqPhV1PNk5omMCc0vb1wSVpbBYGPACXbuZ zsgB6fzNZyG5ocNq0CmkKAH/eE0jWMZzUEwrdfVjAoGAdKDJ3GY4Z+HdoQ95k+u+ Dyg6lILbe/yhUA2D/dZM1UIlyp+vS5Q7dVn3PTa2ueaAuRPkHqmUC0ansbqeta1Y jeByLHjbZvN7G3zjAEKEhzFy1FlVNpTr1uAfAuWg6s1V5Eera+7s6utXLHjr9spB 4pNtsbDCrD7Zbmoswhtarb8CgYBtXl9F7d+rov6xYr+GC3KFYpWJG0AnVbzoctdt v8XXZmkIfOQTSYtIbE30semxyjZ1tEYLBI9qrhw8sC1zydaQuEPYAHZi5IxiOkUV iwuoXgrtngLrrjj6Lqwm80dmswJmuje/XOcU1qhOIDnllnen4coIpc/2ooOVxp3b 2CF11QKBgQCWWmaduO9JM4i2FveVpPPwDdpQvPO3m6Tb/qiwwzIHfXfFZed0qcvS eETFA3gBtlEML/KWm7qI0mLbKFLJROn6XZ1CgPSea6BDrkXsrUDMNmiwlB2QwpQp dFixWVfxX8CnK/W6Xy2NLrqjq6oYPI/GRogfOqujDawPtbEKUBNUOw== -----END RSA PRIVATE KEY-----
第三步:私钥转化成pkcs8格式
尖括号的意思是:将转化好的私钥写到rsa_private_key_pkcs8.pem文件里
openssl pkcs8 -topk8 -inform PEM -in rsa_private_key.pem -outform PEM -nocrypt > rsa_private_key_pkcs8.pem
结果:
C:\Users\miracle>openssl pkcs8 -topk8 -inform PEM -in rsa_private_key.pem -outform PEM -nocrypt > rsa_private_key_pkcs8.pem C:\Users\miracle>
生成文件:
内容如下:
-----BEGIN PRIVATE KEY----- MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQD0rQF5MB5/9sxB 1vwLk5PfJgW34KlWvkoC+52DIfzuIoTgC08iGF5uE80xfnrKvPoNSh17HzAXFLXm 7yyDEMK0aHP+F9qBxf/4eWpen2TdRV5kC9zVxozTyEeQQ6VcAUHs1r+GZPYPOywx g/1E2YA4v5eibJfNf/XiDQrnuNx8JYTV4lazItoBd4oV6ntheNCfoFiDhHHwPFEC WF/yVUj38boGkXaNwG2cPmmo8AMOgwqK+T6kuuyFIMW3prqojua+5BOAGDcRdPuZ k+KYUFwiwTGGExDjItBo2xbQVcN/cKcq8DLEvEGrbcT95EPnGT9fNWxdzt1/lW7V O9PlgQGpAgMBAAECggEBAPG73+HIrcmFnwZJjdkuJAFrAmlJ+GQwOtU5nMRLFyZ7 SkZERhmMc/dTbv5AVLbrAC2TFQ9on82d853GnXacX5F4RWk8TfC7G4t1Aaec2T1X 5Mr5gWRf9xDiJfodK0l8IJMLFEyGgShJMP92xQp5zRnECN87ZLtuehKtCiIoXQX0 6QALfTTcrZRLmMYeAIHPwiNhyOcVqA2AFBUIPwaSEkrUgi+yjnIcl2dG5JT1pYHi 5BgZl7xkaMymEvtKJfsGKVvv6N22ZIhFW+uWyPhdj+NXD1sk8IzYdl9D+KjCJ/LF I1odHjGy1RplY9iC1AjPHDkYo6J3y2YBkrEQp9DdRHUCgYEA+qVqZcM+vD9pDVlA LF6K0wO7xet/89hjKlNCm4IRCauw9fsHkwgCS/OUo+IdKzOf/krom7iqsMz+Ki2f Aj3sEG28zH1ZsnB1HaiqFrIPi3a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