[CDN 技术] squid上建立 SSL 代理转发

Apr 8th, 2008

转载本站文章请注明,转载自:扶凯[http://www.php-oa.com]

本文链接: http://www.php-oa.com/2008/04/08/squid-ssl.html

 今天测试了一下在squid上建一个ssl代理转发.其实也蛮容易的.

https_port 443 cert=/etc/squid/SSL.CRT key=/etc/squid/SSL.KEY defaultsite=ssl.php-oa.com
cache_peer ssl.php-oa.com parent 80 o no-query no-digest originserver name=www
cache_peer_homain www .php-oa.com

 其实真的很容易.是吧.有个 https_port 和 cache_peer 加上那个 ssl 的地址基本就好了.记的 https_port 要加 defaultsite.不加会下面错.

The following error was encountered:

Invalid Request

Some aspect of the HTTP Request is invalid. Possible problems:

Missing or unknown request method

Missing URL

Missing HTTP Identifier (HTTP/1.0)

Request is too large

Content-Length missing for POST or PUT requests

Illegal character in hostname; underscores are not allowed

 

(1.可以使用下面命令可以生成测试用的证书:

openssl req -new -keyout key.pem -nodes -x509 -days 365 -out cert.pem

 pem 是 key 和证书 crt 混用的一种格式.同时包括二者.这种又叫自签名的 key .呵呵 RHCA 的内容还是相当有用的.

 

(2.如果要生成一个证书请求用于申请正式证书请用下面是标准做法:

创建证书

openssl req -new -x509 -days 365 -out server.crt -keyout server.key

创建请求认证的请求证书文件 (CSR),送给证书颁发机构,就会给你公共的证书,加上你自己的 key 就能认证了

openssl req -new -out server.csr -keyout server.key

 如果想给  key 加个密码,创建一个加密的认证 key 的方法

mv server.key server.key.encrypted
openssl rsa -in server.key.encrypted -out server.key

 

(3. 查看相关证书有关内容的详细信息
.cer/.crt是用于存放证书,它是2进制形式存放的,不含私钥.
.pem跟crt/cer的区别是它以Ascii来表示.

检查认证的 crt 证书的内容

openssl x509 -noout -text -in <name>.crt

检查认证的 Keys 的内容

openssl rsa -noout -text -in <name>.key

 

 (4. 常见的 windows 中的证书 PFX 转成可用的 X509 证书文件和 RSA 密钥文件
pfx/p12用于存放个人证书/私钥,他通常包含保护密码,2进制方式.

openssl pkcs12 -in server.pfx -nodes -out server.pem
openssl rsa -in server.pem -out server.key
openssl x509 -in server.pem -out server.crt 

 

Del.icio.us Google书签 Digg Live Bookmark Technorati Furl Yahoo书签 Facebook 百度搜藏 新浪 ViVi 365Key 网摘 天极网摘 和讯网摘 博拉网 POCO 网摘 饭否 QQ 书签 Digbuzz 我挖网 Mister Wong
  1. 瘦瘦的
    Apr 9th, 2008 at 10:04
    Reply | Quote | #1

    你好,我昨天也试了squid的ssl转发。用搜索引擎找了几个https的页面测试
    发现:
    IE7会有提示”安全证书问题可能显示试图欺骗您或截获您向服务器发送的数据”
    继续
    https://account.qq.com/
    https://cp.35.com 随便输入一个用户名和密码都会有出错提示
    https://ecard.163.com
    https://login.live.com

    好像基本都是不行 – -b

  2. 瘦瘦的
    Apr 9th, 2008 at 10:07
    Reply | Quote | #2

    ps:我以前用ccproxy,代理https倒是非常方便,没有任何问题。

  3. kuenzzy
    Jul 7th, 2011 at 09:42
    Reply | Quote | #3

    请教个问题。我现在使用squid做透明代理,默认没有更改squid.conf中ssl配置,现在能够访问https的网站,但是access.log中去没有记录https的信息,请问,有办法解决吗?

  4. admin
    Jul 7th, 2011 at 15:23
    Reply | Quote | #4

    透明代理不要使用 ssl 你拿不到别人的证书,你的没有日志就是因为直接通过网关过的,没通过squid