Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1324560
  • 博文数量: 334
  • 博客积分: 10302
  • 博客等级: 上将
  • 技术积分: 2986
  • 用 户 组: 普通用户
  • 注册时间: 2006-01-12 10:17
文章分类

全部博文(334)

文章存档

2013年(1)

2012年(9)

2011年(4)

2010年(10)

2009年(24)

2008年(64)

2007年(72)

2006年(150)

我的朋友

分类: BSD

2008-08-17 20:03:55

OpenSSL作者 Tom Rhodes.

  许多用户可能并没有注意到 FreeBSD 所附带的 OpenSSL 工具包的功能。 OpenSSL 提供了建立在普通的通讯层基础上的加密传输层;这些功能为许多网络应用和服务程序所广泛使用。

  对 OpenSSL 的一些常见用法包括加密邮件客户的身份验证过程, 基于 Web 的交易如信用卡等等。 许多 ports 如 , 以及 等等都提供了编译进 OpenSSL 支持的方法。

注意: 绝大多数情况下 Ports Collection 会试图使用 security/openssl 除非明确地将 WITH_OPENSSL_BASE make 变量设置为 “yes”。

  FreeBSD 中附带的 OpenSSL 版本能够支持 安全套接字层 v2/v3 (SSLv2/SSLv3) 和 安全传输层 v1 (TLSv1) 三种网络协议,并可作为通用的密码学函数库使用。

注意: 尽管 OpenSSL 支持 , 它能够通过签署来证明个人或公司证书的有效性。这个过程是需要付费的, 当然, 这不是使用证书的必要条件; 然而,这样做会让那些比较偏执的用户感到轻松。

  为了生成证书, 需要使用下面的命令:

# openssl req -new -nodes -out req.pem -keyout cert.pem
Generating a 1024 bit RSA private key
................++++++
.......................................++++++
writing new private key to 'cert.pem'
-----
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]:US
State or Province Name (full name) [Some-State]:PA
Locality Name (eg, city) []:Pittsburgh
Organization Name (eg, company) [Internet Widgits Pty Ltd]:My Company
Organizational Unit Name (eg, section) []:Systems Administrator
Common Name (eg, YOUR name) []:localhost.example.org
Email Address []:trhodes@FreeBSD.org

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:SOME PASSWORD
An optional company name []:Another Name

  请注意, 在 “Common Name” 提示后面我们输入的是一个域名。这个提示要求输入服务器的名字, 这个名字今后将用于完成验证过程;如果在这里输入域名以外的内容, 那么证书也就失去其意义了。 您还可以指定一些其他的选项,比如证书的有效期, 以及使用的加密算法等等。 这些选项的完整列表, 可以在 联机手册中找到。

  在您执行前述命令的目录中将生成两个文件。 证书申请, 即 req.pem, 可以发给一家发证机构, 它将验证您输入的凭据的真实性,并对申请进行签名, 再把证书返还给您。 第二个文件的名字将是 cert.pem, 它包含了证书的私钥, 应被全力保护; 如果它落入别人手中,则可以被用来伪造您 (或您的服务器)。

  如果不需要来自

  那么有了这些文件可以做些什么呢? 一个比较典型的用法是用来加密 Sendmail 来连接邮件服务器:

# telnet example.com 25
Trying 192.0.34.166...
Connected to example.com.
Escape character is '^]'.
220 example.com ESMTP Sendmail 8.12.10/8.12.10; Tue, 31 Aug 2004 03:41:22 -0400 (EDT)
ehlo example.com
250-example.com Hello example.com [192.0.34.166], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-AUTH LOGIN PLAIN
250-STARTTLS
250-DELIVERBY
250 HELP
quit
221 2.0.0 example.com closing connection
Connection closed by foreign host.

  如果输出中出现了 “STARTTLS” 则说明一切正常。

阅读(2075) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~