欢迎 HiLanny 加入本站!
 免费注册  用户登陆  汇款方式  汇款确认  产品报价  联系我们  帮助中心
加入收藏
设为首页
会员体系
申请VIP
网站首页 光盘超市 软件下载 技术文章 专题 用户中心 VIP会员 技术论坛 网站留言 娱乐中心 卓越资源
今天是:2008年11月21日 星期五  您现在位于: 首页 → 技术文章 → 建立MySQL的SSL...
   建立MySQL的SSL连接通道
作者:jxtm.cublog.cn  出处:jxtm.cublog.cn  更新时间: 2007年05月22日 

通常我们在编译MySQL的时候都加入了with-openssl选项,但这并不代表MySQL已经支持了OpenSSL连接,我们可以通过如下命令进行检测: 

SHOW VARIABLES LIKE 'have_openssl';
如果显示DISABLED则表明MySQL尚不支持OpenSSL。 
建立SSL证书
;;建几个目录和文件
mkdir /usr/local/myssl
cd /usr/local/myssl
mkdir private newcerts
touch index.txt
echo "01" > serial
;;拷贝一份OpenSSL的缺省配置到当前目录
cp /usr/local/openssl/openssl.cnf .
;;修改当前目录下的openssl.cnf,将./demoCA替换为/usr/local/myssl,replace的具体用法见man
replace ./demoCA /usr/local/myssl -- /usr/local/myssl/openssl.cnf
;;建立根证书
openssl req -new -x509 -keyout private/cakey.pem -out cacert.pem -config openssl.cnf
# Sample output:
# Using configuration from /usr/local/myssl/openssl.cnf
# Generating a 1024 bit RSA private key
# ................++++++
# .........++++++
# writing new private key to '/usr/local/myssl/private/cakey.pem'
# Enter PEM pass phrase:
# Verifying password - Enter PEM pass phrase:
# -----
# 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]:ZJ
# Locality Name (eg, city) []:JX
# Organization Name (eg, company) [Internet Widgits Pty Ltd]:Centeur CA
# Organizational Unit Name (eg, section)[] :HN
# Common Name (eg, YOUR name)[] :MySQL admin
# Email Address []:lypdarling@gmail.com
;;建立服务端证书
openssl req -new -keyout server-key.pem -out server-req.pem -days 3600 -config openssl.cnf
# Sample output:
# Using configuration from /usr/local/myssl/openssl.cnf
# Generating a 1024 bit RSA private key
# ..++++++
# ..........++++++
# writing new private key to '/usr/local/myssl/server-key.pem'
# Enter PEM pass phrase:
# Verifying password - Enter PEM pass phrase:
# -----
# 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]:ZJ
# Locality Name (eg, city) []:JX
# Organization Name (eg, company) [Internet Widgits Pty Ltd]:Centeur CA
# Organizational Unit Name (eg, section) []:HN
# Common Name (eg, YOUR name) []:MySQL server
# Email Address []:lypdarling@gmail.com
#
# Please enter the following 'extra' attributes
# to be sent with your certificate request
# A challenge password []:
# An optional company name []:
;;移除server-key中的passphrase(可选)
openssl rsa -in server-key.pem -out server-key.pem
;;签署服务端证书
openssl ca -policy policy_anything -out server-cert.pem -config openssl.cnf -infiles server-req.pem
# Sample output:
# Using configuration from /usr/local/myssl/openssl.cnf # Enter PEM pass phrase:
# Check that the request matches the signature
# Signature ok
# The Subjects Distinguished Name is as follows
# countryName :PRINTABLE:'CN'
# organizationName :PRINTABLE:'Centeur CA'
# commonName :PRINTABLE:'MySQL admin'
# Certificate is to be certified until May 18 16:05:46 2006 GMT
# (365 days)
# Sign the certificate? [y/n]:y
#
#
# 1 out of 1 certificate requests certified, commit? [y/n]y
# Write out database with 1 new entries
# Data Base Updated
;;建立客户端证书
openssl req -new -keyout client-key.pem -out client-req.pem -days 3600 -config openssl.cnf
# Sample output:
# Using configuration from /usr/local/myssl/openssl.cnf
# Generating a 1024 bit RSA private key
# .....................................++++++
# .............................................++++++
# writing new private key to '/usr/local/myssl/client-key.pem'
# Enter PEM pass phrase:
# Verifying password - Enter PEM pass phrase:
# -----
# 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]:ZJ
# Locality Name (eg, city) []:JX
# Organization Name (eg, company) [Internet Widgits Pty Ltd]:Centeur CA
# Organizational Unit Name (eg, section) []:HN
# Common Name (eg, YOUR name) []:MySQL user
# Email Address []:lypdarling@gmail.com
#
# Please enter the following 'extra' attributes
# to be sent with your certificate request
# A challenge password []:
# An optional company name []:
;;移除client-key中的passphrase(可选)
openssl rsa -in client-key.pem -out client-key.pem
;;签署客户端证书
openssl ca -policy policy_anything -out client-cert.pem -config openssl.cnf -infiles client-req.pem
# Sample output:
# Using configuration from /usr/local/myssl/openssl.cnf
# Enter PEM pass phrase:
# Check that the request matches the signature
# Signature ok
# The Subjects Distinguished Name is as follows
# countryName :PRINTABLE:'CN'
# organizationName :PRINTABLE:'Centeur CA'
# commonName :PRINTABLE:'MySQL user'
# Certificate is to be certified until May 18 16:08:20 2006 GMT
# (365 days)
# Sign the certificate? [y/n]:y
#
#
# 1 out of 1 certificate requests certified, commit? [y/n]y
# Write out database with 1 new entries
# Data Base Updated
修改/etc/my.cnf,添加如下内容:
[client]
ssl-ca=/usr/local/myssl/cacert.pem
ssl-cert=/usr/local/myssl/client-cert.pem
ssl-key=/usr/local/myssl/client-key.pem
[mysqld]
ssl-ca=/usr/local/myssl/cacert.pem
ssl-cert=/usr/local/myssl/server-cert.pem
ssl-key=/usr/local/myssl/server-key.pem
重启mysql服务
/usr/local/etc/rc.d/mysql-server restart
 

 
 原文地址 http://ipoplar.com/2007/01/mysqlssl.html  
 
 
 (本文已被浏览 2242 次)
 发布人:sdccf
 → 推荐给我的好友
上篇文章:IBM X365安装SCO OpenServer5....
下篇文章:用adesklets打造FreeBSD的个性桌面
 相关文章:
MySQL优化系列 MYSQL备份策略
实现MySQL的Replication Linux下安装支持SSL连接的Mysql
MySQL安装与配置 MySQL SQL Profiler性能分析器
PHPMyadmin配置文件详解 一组新的PHP插件实现MySQL的基础事务
MySQL 5 C API 访问数据库例子程序 实现基于php和MySQL的动态树型菜单
加速动态网站之 MySQL索引分析和优化 用PHP写MySQL数据库的用户认证系统
Mysql 5.0.22 Cluster for RedHat AS4-U2 在Linux高负载下mysql数据库彻底优化
Redhat AS4下架设MYSQL-MAX5.0.27集群 MySQL数据库中文模糊检索问题
MySQL各存储引擎的区别及其启动方法 linux下mysql编程示例
用C语言操作MySQL数据库 关于MySQL嵌套查询

相关搜索
查看百度中关于建立MySQL的SSL连接通道的更多内容
查看google中关于建立MySQL的SSL连接通道的更多内容
   文章分类
操作系统 |
SCO_UNIX  Sun_Solaris  IBM_AIX  HP_UX  Linux  BSD  Tru64_UNIX 
通用UNIX知识  Windows  Minix 
程序设计 |
Shell编程  C/C++  汇编  PHP  JAVA  Perl  Python 
ASP/HTML  XML  中间件 
数据库 |
Oracle  Informix  Sybase  Fox  DB2  SQL  MySQL 
PostgreSQL 
网络应用 |
网络应用 
计算机硬件 |
计算机主机  打印机  路由器  交换机  终端  磁带机  MO 
刻录机  终端服务器  调制解调器 
   文章评论
  → 评论内容 (点击查看)   共0条评论,每页显示5条评论   浏览所有评论
(没有相关评论)
  → 发表我的评论
您的姓名: 您的Email:
评论内容:
250字内
发表评论:      发表评论须知 →
  • 尊重网上道德,遵守《全国人大常委会关于维护互联网安全的决定》及中华人民共和国其他各项有关法律法;
  • 本站有权保留或删除您发表的任何评论内容;
  • 关于我们 ┋  网站留言 ┋  网站地图 ┋  友情链接 ┋  与我在线 ┋  汇款确认 ┋  管理 ┋  TOP
    Linux.Unix爱好者家园  http://www.unix-cd.com/
    联系我们:sdccf@163.com
    腾讯QQ: 7644599
    备案序号:鲁ICP备05000455号
    Copyright (c) 2001-2008 Unix-cd.com. All Rights Reserved.