分类:
2008-07-23 14:28:50
Stunnel 可以非常方便的实现端口加密转发功能,我们可以用他来实现很多加密端口的传输。这里只做了简单的介绍,更深层次的功能还有待进一步挖掘。
Stunnel网站
下载源码
./configure --prefix=/work/stunnel
--with-nspr-includes=/usr/include/nspr
--with-nspr-libs=/usr/lib
--with-nss-includes=/usr/include/nss
--with-nss-libs=/usr/lib
make; makeinstall;
测试发现
Red Hat Enterprise Linux AS release 3 (Taroon Update 4) 进入下面目录
/usr/share/ssl/certs
Red Hat Enterprise Linux Server release 5 (Tikanga) 进入下面目录
/etc/pki/tls/certs
执行一下命令
make stunnel.pem
通过默认默认目录下的Makefile文件对stunnel的支持我们可以生成一个支持stunnel.pem的密钥。
cp -rf stunnel.pem /work/stunnel/etc/stunnel/ 把密钥拷贝到对应的目录下。
mkdir -p /work/stunnel/var/run/stunnel/
chown -R nobody:nobody /work/stunnel/ 修改为nobody权限
cd /work/stunnel
vi etc/stunnel/stunnel.conf
增加以下内容(需要修改一下目录指向和ip端口就可以用了!),
stunnel 3版和4版本有很大区别,4版本的注释有些时候是“#”,现在拿到的最新版本又是“;”.这个自己看默认配置吧!
; Sample stunnel configuration file
; Copyright by Michal Trojnara 2002
; Comment it out on Win32 cert
cert = /work/stunnel/etc/stunnel/stunnel.pem
;chroot = /work/stunnel/var/run/stunnel/
; PID is created inside chroot jail
;pid =/work/stunnel/var/run/stunnel/stunnel.pid
setuid = root
setgid = root
; Workaround for Eudora bug
;options = DONT_INSERT_EMPTY_FRAGMENTS
; Authentication stuff
;verify = 2
; don't forget about c_rehash CApath
; it is located inside chroot jail:
;CApath = /certs
; or simply use CAfile instead:
;CAfile = /work/stunnel/etc/stunnel/certs.pem
; CRL path or file (inside chroot jail):
;CRLpath = /crls
; or simply use CAfile instead:
;CRLfile = /work/stunnel/etc/stunnel/crls.pem
; Some debugging stuff
; 注意调整调试级别,如果测试正常设置低一点的模式,否则可能日志过大1-7(7最大)
debug = 1
output = stunnel.log
; Use it for client mode
;client = yes
; Service-level configuration
[pop3s]
accept = 995
connect = 172.16.100.168:110
[imaps]
accept = 993
connect = 172.16.100.168:143
[ssmtp]
accept = 465
connect = 172.16.100.168:25
[s1]
accept = 5000
connect = mail.osw.pl:110
; delay = yes
[s2]
accept = 5001
connect = mail.osw.pl:25
;[https]
;accept = 443
;connect = 80
;TIMEOUTclose = 0
;inetd mode must define a remote host or an executable
/work/stunnel4.25/bin/stunnel 服务就可以启动了。
如果配置了 output = stunnel.log 在当前目录下就会有一个日志文件了。