安装
openssl
# tar –zxvf openssl
# cd openssl
# ./config --prefix=/usr/local/openssl
# make
# make install
加密解密
传统加密(对称加密)
openssl enc –ciphername(
加密算法
) –k password
(口令)
–in file
(被加密的算法)
-out
(输出文件)
file
解密
openssl enc –ciphername –k password
-d –in file -out file
加密算法有:
base64,des,des3,rc2,rc5,aes256
例如:
/bin/openssl enc –des3 –k boobooke –in pt.txt –out ct.bin
//
加密
/bin/openssl enc –des3 –d
–k boobooke –in ct.bin –out pt1.txt
//
解密
非对称加密
Generate the private/public key
Openssl genrsa –out file 1024
例如:
Openssl genrsa –out priv.key 1024
//
用
rsa
算法生成私钥
(priv.key)
Openssl rsa –in file –pubout
例如:
Openssl rsa –in priv.key –pubout>pub.key
//
用私钥
priv.key
生成公钥
,
并重定向到
pub.key
这个文件里面
Encrypt the file with public key
Openssl rsautl –in file –out file –inkey file –pubin –encrypt
例如:
Openssl rsautl –in test.txt –out test.bin –inkey pub.key –pubin –encrypt
//
利用公钥文件(
pub.key
)对
text.txt
文件进行加密,生成加密后的文件
text.bin
Decrypt the file the private key
Openssl rsautl –in file –out file –inkey file –decrypt
例如:
Openssl rsautl –in text.bin –out text1.txt –inkey priv.key –decrypt
//
利用私钥
priv.key
对公钥加密的
text.bin
进行加密的文件进行解密,生成解密后的文件是
text1.txt
Use openssl sign/verify functions(
数字签名
)
Generate the private/public key
生成密钥对
Openssl genrsa –out file 1024
Openssl rsa –in file –pubout
Sign the file with the private key
Openssl rsautl –in file –out file –inkey file –sign
例如:
Openssl rsatul –in test.txt –out test.sig –inkey priv.key –sign
//
利用私钥对
test.txt
进行加密也就是签名
Openssl rsautl –in file –out file –inkey file –pubin –verify
例如:
Openssl rsautl –in test.sig –out test2.txt –inkey pub.key –pubin –verify //
利用公钥对私钥加密后的文件(
test.sig
)进行解密或是认证
Hash functions
(
hash
函数)……
MD5 SHA1
作用:主要是验证文件的完整性,没有被别人篡改!
Generate the md5 hash result
Openssl dgst –md5 file
或
Md5sum file
例如:
Openssl dgst –md5 openssl.tar.gz
//
生成
MD5
值
Md5sum openssl.tar.gz
Generate the sha1 hash result
Openssl dgst –sha1file
或
Sha1sum file
例如:
Openssl –dgst –sha1 openssl.tar.gz
//
生成
sha1
值
Install apache
Configure the environment
tar –zxvf httpd-2.0.63.tar.gz
cd httpd-2.0.63
./configure –prefix=/usr/local/apache –enable-ssl –with-ssl=/usr/local/openssl
make
make install
Configure ssl in apache
openssl req -new -x509 -days 30 -keyout server.key -out server.crt -subj '/CN=Test Only Certifiecate'
或者
Openssl
req –new –x509 –days 365 –sha1 –nodes –newkey rsa:1024 keyout
server.key –out server.crt –subj ‘/O=Seccure/OU=Seccure
Labs/CN=www.secdemo.com’
Cpy the .key and .crt file to the proper directory
//
一般都是存放在
apache
的
conf
目录下面,具体存放路径是在
apache
的配置文件中定义的
Vi httpd.conf
<IfModule mod_ssl.c>
Include conf/ssl.conf
//ssl
的配置文件被包含在
conf/ssl.conf
</IfModule>
Vi conf/ssl.conf
SSLCertificateKeyFile /usr/local/apache/conf/ssl.crt/server.key
//server.key
存放路径
SSLCertificateFile /usr/local/apache/conf/ssl.crt/server.crt
//server.crt
存放路径
Apache2.2
直接启动
apache
服务就可以启动
SSL
Apache2.0
启动
ssl
:
apachectl startssl
//
端口号为
443
端口
Vi conf/ssl.conf
<Directory />
SSLRequireSSL
//
此目录只允许使用
https
协议访问
</Directory>
<Directory /usr/local/apache/htdocs/ssldemo>
SSLRequireSSL
</Directory>//ssldemo
这个目录必须使用
https
协议访
问,应为利用
ssl
安全访问存在着密钥的
加密解密以及传送,所以访问会很慢,所
以一般都是把一些需要中到
https
协议访
访问的程序放在一个目录中,而其他的站
点依然用
http
协议访问
分享到:
相关推荐
linux中openssl安装配置手册 该文档用于在centos中如何安装配置https协议的教程文档。
Apache2.2.4+Subverson1.7.6+Openssl安装配置,一步步安装配置,肯定能部署成功。祝你好运!
包括了openssl_win64版安装包,ActivePerl安装包,windows安装配置openssl教程,使用openssl配置tomcat ssl双向认证教程(仅安装就不需要最后一个教程)
网络上很难找到非常详细的...本文档通过真实的实践经验,从安装OpenSSL和Nginx,到利用openssl生成证书,配置nginx的https(包括配置http请求转发到https)等,详细总结出nginx配置https的步骤,最终能帮助你配置成功。
让你更好的的把握OpenSSL的安装和配置过程
OpenSSL是一个开源的ssl技术,由于我需要使用php相关功能,需要获取https的文件所以必须安装这个东西了,下面我整理了两种关于OpenSSL安装配置方法。 安装环境: 操作系统:CentOs7安静 OpenSSL Version:...
NULL 博文链接:https://hyamine.iteye.com/blog/773474
windows 32位操作系统下安装配置openssl环境,及安装过程中一些错误解决
很好用的一款Oracle数据库管理工具,经典界面,64位中文版,附注册机和详细安装配置教程,无需安装Oracle客户端。
BIEE 安装与配置,简单明了,方便快捷
Oracle客户端安装、plsql developer X64安装配置使用-附件资源
NULL 博文链接:https://fp-forever.iteye.com/blog/1412551
资源名称:CentOS 6.5 x64下安装19实体节点Hadoop 2.2.0集群配置指南内容简介: CentOS 6.5 x64下安装19实体节点Hadoop 2.2.0集群配置指南主要讲述的是CentOS 6.5 x64下安装19实体节点Hadoop 2.2.0集群配置指南;...
openssl打包 附带 windows下详细使用安装配置
PCL-1.8.0-AllInOne VS2013 Win8 X64 安装配置及部分问题解决方法-附件资源
apache-tomcat-7.0.42-windows-x64免安装包
Qt安装配置文件(Qt Linux-x64-5.3.2安装) qt-opensource-linux-x64-android-5.3.2安装配置过程