[color=Red]转载请注明出处。[/color]
1. 安装 OpenSSL:
下载 OpenSSL Version 0.9.6 (www.openssl.org)
shell> zcat 0.96l.tar.gz | tar xvf -
shell> ./config
shell> make
shell> make install
2. 安装 MySQL:
下载 MySQL Version 4.0.14 Source (mysql-4.0.14.tar.gz)
shell> groupadd mysql
shell> useradd -g mysql mysql
shell> gunzip < mysql-VERSION.tar.gz | tar -xvf -
shell> cd mysql-VERSION
shell> ./configure --prefix=/usr/local/mysql --with –openssl --with -vio
shell> make
shell> make install
shell> cp support-files/my-medium.cnf /etc/my.cnf
shell> cd /usr/local/mysql
shell> bin/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql var
shell> chgrp -R mysql .
shell> bin/mysqld_safe --user=mysql &
3. 修改mysql密码及访问权限 ([color=Red]根据需要。可能造成安全问题[/color])
shell> cd /usr/local/mysql/bin/
shell> ./mysql -u root –p
mysql> INSERT INTO mysql.user VALUES ('%','root', PASSWORD('1qw23e'),'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0);
4. 生成SSL证书
DIR=`pwd`/openssl
PRIV=$DIR/private
mkdir $DIR $PRIV $DIR/newcerts
cp /usr/share/ssl/openssl.cnf $DIR
replace ./demoCA $DIR -- $DIR/openssl.cnf
# Create necessary files: $database, $serial and $new_certs_dir
# directory (optional)
touch $DIR/index.txt
echo "01" > $DIR/serial
# Generation of Certificate Authority(CA)
openssl req -new -x509 -keyout $PRIV/cakey.pem -out $DIR/cacert.pem \
-config $DIR/openssl.cnf
Note : if you were requested to enter "PEM pass", please enter different "PEM pass" in the following steps.
# Create server request and key
openssl req -new -keyout $DIR/server-key.pem -out \
$DIR/server-req.pem -days 3600 -config $DIR/openssl.cnf
# Remove the passphrase from the key (optional)
openssl rsa -in $DIR/server-key.pem -out $DIR/server-key.pem
# Sign server cert
openssl ca -policy policy_anything -out $DIR/server-cert.pem \
-config $DIR/openssl.cnf -infiles $DIR/server-req.pem
# Create client request and key
openssl req -new -keyout $DIR/client-key.pem -out \
$DIR/client-req.pem -days 3600 -config $DIR/openssl.cnf
# Remove a passphrase from the key (optional)
openssl rsa -in $DIR/client-key.pem -out $DIR/client-key.pem
# Sign client cert
openssl ca -policy policy_anything -out $DIR/client-cert.pem \
-config $DIR/openssl.cnf -infiles $DIR/client-req.pem
5. 修改选项文件 /etc/my.cnf
[client]
ssl-ca=$DIR/cacert.pem
ssl-cert=$DIR/client-cert.pem
ssl-key=$DIR/client-key.pem
[mysqld]
ssl-ca=$DIR/cacert.pem
ssl-cert=$DIR/server-cert.pem
ssl-key=$DIR/server-key.pem
6. 测试启动mysql
$DIR 是选项文件my.cnf 的路径
shell> mysqld --defaults-file=$DIR/my.cnf &
Then invoke a client program using the same option file:
shell> mysql --defaults-file=$DIR/my.cnf
执行以下语句,如果返回以下结果,安装完全成功
mysql> SHOW VARIABLES LIKE 'have_openssl';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| have_openssl | YES |
+---------------+-------+
7. 启动MySQL daemon
/usr/local/libexec/mysqld -u mysql & 或者 /usr/local/sbin/mysqld &
[color=Red]
PS:国内这方面资料不多。。我也是看mysql 帮助和install 帮助弄的。希望没有误人子弟。:)[/color]
macrodba 回复于:2006-01-11 16:27:42
支持一下
yejr 回复于:2006-01-12 08:44:13
great,支持原创
goodcjh2005 回复于:2006-01-14 14:00:12
一般
李某人 回复于:2006-01-14 23:29:56
Good
OnlYeR 回复于:2006-02-15 20:40:07
超级潜水员吖
ipaddr 回复于:2006-02-16 09:45:08
不错,支持一个。
macrodba 回复于:2006-02-16 13:10:07
继续努力
初学vb 回复于:2006-03-23 14:44:25
好象应用不多,能否举个实际例子??
rardge 回复于:2006-03-29 09:10:54
引用:原帖由 初学vb 于 2006-3-23 14:44 发表
好象应用不多,能否举个实际例子??
举什么例子?这个本身就是个例子啊。
就是 mysql 客户端 和 服务器端 通过 SSL 来建立加密连接和传送数据,防止传送过程中被窃听。
实际应用中速度会变慢些,但是信息传递安全了。
不过呢,这个应用要使用在远程连接上才是有意义的,如果 应用程序服务器端 和 MySQL 在同一台机器上,而且都是通过 localhost 来连接 MySQL 的话,就没什么意义了。这种情况下应该 应用程序的服务器端和客户端 之间建立 SSL 连接。
看楼主的例子,应该是远程连接了,因为使用的账号是 root@%。
[ 本帖最后由 rardge 于 2006-3-29 09:12 编辑 ]
oceanb0y 回复于:2006-03-30 15:08:10
great!
sundycindy 回复于:2006-03-31 15:42:22
如何在编程开发包中使用 加密传输呢?
sundycindy 回复于:2006-04-10 10:51:11
有没有人调试成功过,我按照使用手册所有步骤操作都成功了,但是用客户端连接测试时还是没有采用通讯加密。很是疑惑!大侠们能给些建议么?
IM.wewe 回复于:2006-11-29 19:39:49
我弄了半天,查了半天.还是不知道实际应用中的意义
像我现在有套程序需要调用服务器中的数据库,进行这样的操作的话,就必须是每台安装这套程序的软件都要有client-key,windows系统下该怎么样做?这样的设置又能带来安全上多大的提升?
国内关于ssl教程类的文章实在太少了,说得都深奥难懂,实际应用的实例讲解却不多
|