三 实现SMTP的加密
1.SMTP的证书的请求基本上与POP3的想像,下面只发一些步骤
[root@localhost ~]# mkdir -pv /etc/sendmail/certs
mkdir: 已创建目录 “/etc/sendmail”
mkdir: 已创建目录 “/etc/sendmail/certs”
[root@localhost ~]# cd /etc/sendmail/certs/
产生私钥
[root@localhost certs]# openssl genrsa 1024 > sendmail.key
Generating RSA private key, 1024 bit long modulus
......++++++
................................................++++++
e is 65537 (0x10001)
生成请求证书
[root@localhost certs]# openssl req -new -key sendmail.key -out sendmail.csr
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) [GB]:CN
State or Province Name (full name) [Berkshire]:HENAN
Locality Name (eg, city) [Newbury]:Zhengzhou
Organization Name (eg, company) [My Company Ltd]:sina
Organizational Unit Name (eg, section) []:smtp
Common Name (eg, your name or your server's hostname) []: smtp.sina.com
Email Address []:
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name
CA服务器颁发证书
[root@localhost certs]# openssl ca -in sendmail.csr -out sendmail.cert
Using configuration from /etc/pki/tls/openssl.cnf
Check that the request matches the signature
Signature ok
Certificate Details:
Serial Number: 2 (0x2)
Validity
Not Before: Nov 15 10:53:33 2012 GMT
Not After : Nov 15 10:53:33 2013 GMT
Subject:
countryName = CN
stateOrProvinceName = HENAN
organizationName = sina
organizationalUnitName = smtp
commonName = smtp.sina.com
X509v3 extensions:
2.修改此证书及私钥的权限
[root@localhost certs]# cd /etc/sendmail/certs
[root@localhost certs]# chmod 600 *
注:这一步一定要做,不然的话,sendmail的加密设置是不成功的.
3.修改配置文件,使服务器支持smtps加密
[root@localhost ~]# vim /etc/mail/sendmail.mc
修改成如下
60 define(`confCACERT_PATH', `/etc/pki/CA')dnl
61 define(`confCACERT', `/etc/pki/CA/cacert.pem')dnl
62 define(`confSERVER_CERT', `/etc/sendmail/certs/sendmail.cert')
63 define(`confSERVER_KEY', `/etc/sendmail/certs/sendmail.key')
134 DAEMON_OPTIONS(`Port=smtps, Name=TLSMTA, M=s')dnl
4.重启sendmail服务器
[root@localhost ~]# service sendmail restart
关闭 sm-client: [确定]
关闭 sendmail: [确定]
启动 sendmail: [确定]
启动 sm-client: [确定]
4. 测试
首先对客户端用户进行设置

发送邮件检测是否正确
直接点击是即可
也可使用抓包来验证
[root@localhost yum.repos.d]# tshark -ni eth0 -R "tcp.port eq 25"
