6、运行“nmake -f ms\ntdll.mak install”安装编译后的OpenSSL到指定目录。html
7、查看安装结果C:\usr\local\ssl或C:\openssl-0.9.8.e下包含了三个文件夹Bin、include、lib。bin下包括openssl.exe(openssl指令程序)、ssleay32.dll(ssl协议动态库)、libeay32.dll(密码算法库)。lib下包括libeay32.lib,ssleay32.lib。Include目录包括了OpenSSL开发设计的头文件。node
至此,OpenSSL在windows下编译完成了。linux
最后一步编译时可能出现错误:“NMAKE : fatal error U1077: 'ml' : return code '0x1' Stop.”,产生这种错误的可能缘由是vc6的bin目录下没有ml.exe这个文件。该文件包含在MASM程序中。个人解决办法是到网上下载了一个MASM程序(http://www.masm32.com/masmdl.htm),安装上以后把ml.exe拷贝到VC6的bin目录下便可解决。git
打开openssl.exe文件输入命令算法
1. 生成RSA密钥的方法windows
key通常分为public key和private key,在openssl中,private key中包含了public key的信息,因此public key不须要单首创建. 如何建立一个RSA key?安全
openssl.exe genrsa -des3 -out privkey.pem 2048 (须要添加密码保护)dom
这个命令会生成一个2048位的密钥,同时有一个des3方法加密的密码,若是你不想要每次都输入密码,能够改为:测试
openssl.exe genrsa -out privkey.pem 2048ui
建议用2048位密钥,少于此可能会不安全或很快将不安全。
2. 生成一个证书请求
openssl req -new -key privkey.pem -outcert.csr
这个命令将会生成一个证书请求,固然,用到了前面生成的密钥privkey.pem文件
这里将生成一个新的文件cert.csr,即一个证书请求文件。
3. 生成证书
拿到上面的证书请求文件,去数字证书颁发机构(即CA)申请一个数字证书。CA会给你一个新的文件cacert.pem,那才是你的数字证书。
若是是本身作测试,那么证书的申请机构和颁发机构都是本身。就能够用下面这个命令来生成证书:
openssl req -new -x509 -key privkey.pem -out cacert.pem -days 1095
这个命令将用上面生成的密钥privkey.pem生成一个数字证书cacert.pem
参考文档:http://blog.chinaunix.net/uid-20479991-id-216269.html
http://blog.csdn.net/zh516846937/article/details/40188065
http://blog.sina.com.cn/s/blog_4913c1f3010008r7.html
http://my.oschina.net/sad7girl/blog/73711
C:\CA256>openssl genrsa -aes256 -out rootca.key 8192
Loading 'screen' into random state - done
Generating RSA private key, 8192 bit long modulus
......................++
...........................................++
e is 65537 (0x10001)
Enter pass phrase for rootca.key:
Verifying - Enter pass phrase for rootca.key:
C:\CA256>openssl req -sha256 -new -x509 -days 1826 -key rootca.key -out rootca.crt
Enter pass phrase for rootca.key:
Loading 'screen' into random state - done
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) [AU]:CN
State or Province Name (full name) [Some-State]:sichuan
Locality Name (eg, city) []:chengdu
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Root Bitnum CA
Organizational Unit Name (eg, section) []:bitnum
Common Name (e.g. server FQDN or YOUR name) []:Root Bitnum CA
Email Address []:Root Bitnum CA
C:\CA256>cd C:\C256
C:\C256>openssl genrsa -out server-key.pem 1024
Loading 'screen' into random state - done
Generating RSA private key, 1024 bit long modulus
...++++++
.++++++
e is 65537 (0x10001)
C:\C256>openssl req -new -sha256 -out server-req.csr -key server-key.pem
Loading 'screen' into random state - done
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) [AU]:CN
State or Province Name (full name) [Some-State]:sichuan
Locality Name (eg, city) []:chengdu
Organization Name (eg, company) [Internet Widgits Pty Ltd]:bitnun server
Organizational Unit Name (eg, section) []:bitnun
Common Name (e.g. server FQDN or YOUR name) []:192.168.1.116
Email Address []:192.168.1.116
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:123456
An optional company name []:bitnum
C:\C256>openssl x509 -req -sha256 -in server-req.csr -out server-cert.pem -signkey server-key.pem -CA rootca.crt -CAkey rootca.key -CAcreateserial -days 3650
Loading 'screen' into random state - done
Signature ok
subject=/C=CN/ST=sichuan/L=chengdu/O=bitnun server/OU=bitnun/CN=192.168.1.116/emailAddress=192.168.1.116
Getting Private key
Getting CA Private Key
Enter pass phrase for rootca.key:
C:\C256>openssl pkcs12 -export -clcerts -in server-cert.pem -inkey server-key.pem -out server.p12
Loading 'screen' into random state - done
Enter Export Password:
Verifying - Enter Export Password:
C:\C256>