使用stunnel双向证书认证加密samba的数据传输
来源:互联网 发布:csp绘画软件模型 编辑:程序博客网 时间:2024/05/22 12:58
服务端ubuntu server 14.04
客户端windows 7
服务端ubuntu
以下在ubuntu server上操作
samba的设置
在配置文件中限制只服务内网接口和lo
interfaces = eth1 127.0.0.0/8
bind interfaces only = yes
stunnel的安装
ubuntu上使用stunnel4做服务端
sudo apt-get install stunnel4
把文件/etc/default/stunnel4中的
ENABLED=1设置为1使能自动启动
证书准备
参考http://blog.csdn.net/zahuopuboss/article/details/8664446
准备CA证书,并使用CA签发2份证书
1份给服务端使用,1份给客户端使用
如果有多个客户端,则签发多份
例如:cacert.pem,serverprivkey.pem,servercert.pem,clientprivkey.pem,clientcert.pem
使用命令openssl x509 -hash -in servercert.pem -noout得到证书的哈希值XXXXXXXX
以XXXXXXXX.0为名称复制servercert.pem
对客户端证书同样操作得到以哈希值命名的证书文件
用于服务端与客户端进行相互的证书认证
服务端stunnel配置
配置文件/etc/stunnel/stunnel.conf
内容如下:
chroot = /var/lib/stunnel4/
setuid = stunnel4
setgid = stunnel4
pid = /stunnel4.pid
debug = 7
output = /stunnel.log
ciphers = DHE-RSA-AES256-SHA256
client = no
cert = /etc/stunnel/servercert.pem
key = /etc/stunnel/serverprivkey.pem
verify = 3
CApath = /certs
CAfile = /etc/stunnel/cacert.pem
[smb]
accept = 9999
connect = 445
CApath是相对chroot路径的,在chroot路径下建立certs目录
把以哈希值命名的客户端证书放置在CApath路径下
验证方式verify设置为3,使用本地保存的证书(CApath下哈希值命名的证书)来验证对端的证书
客户端win7
以下在windows上操作
添加loop接口
控制面板 -> 设备管理器 -> 菜单操作 -> 添加过时硬件
手动选择 -> 网络适配器
Microsoft -> Microsoft Loopback Adapter
添加完成后
打开网络和各项中心 -> 更改适配器设置 -> 右击Loopback接口 -> 属性
使用的项目只保留IPv4 -> 进入该项的高级设置 -> 禁用NetBIOS
设置Loopback接口IP为10.0.0.1
关闭共享服务
控制面板 -> 管理工具 -> 服务
禁用server服务
以便stunnel可以监听445端口
重启电脑
客户端stunnel下载
https://www.stunnel.org/downloads.html
下载installer.exe安装
stunnel设置
右击状态栏图标,点击edit configration
内容如下:
debug = 7
client = yes
[smb]
accept = 10.0.0.1:445
connect = serveripordomain:9999
CAfile = cacert.pem
verify = 3
cert = clientcert.pem
key = clientprivkey.pem
CApath = ./certs/
在安装路径下的config目录内建立certs目录
把以哈希值命名的服务端证书放到cert目录内
验证方式verify设置为3,以便验证服务端
点击reload configration
使用\\10.0.0.1\xxx访问samba服务
验证方式说明
verify = 3
Verify the peer against a locally installed certificate.
不但会使用CA验证对端证书的有效性(同level2,可以有效避免中间人攻击)
还会验证CApath是否存在一份对端证书的拷贝(避免证书滥用,因为CA颁发的证书中不一定都是用来连接stunnel的)
双方都使用verify = 3进行互相认证
参考
https://www.stunnel.org/static/stunnel.html
https://www.stunnel.org/pipermail/stunnel-users/2013-September/004337.html
https://www.stunnel.org/downloads.html
http://blog.csdn.net/zahuopuboss/article/details/8664446
https://gigacog.com/blog/2016/02/cifs-over-ssl-with-stunnel-and-windows-client/
https://www.digitalocean.com/community/tutorials/how-to-set-up-an-ssl-tunnel-using-stunnel-on-ubuntu
https://wiki.netbsd.org/tutorials/how_to_secure_samba_with_stunnel/
- 使用stunnel双向证书认证加密samba的数据传输
- 使用证书加密认证
- Linux下使用Stunnel加密Redis,实现ssl认证
- 使用 Stunnel 加密
- SSL双向认证以及证书的制作和使用
- SSL双向认证以及证书的制作和使用
- SSL双向认证原理以及期间证书的使用
- SSL双向认证以及证书的制作和使用
- 使用 Stunnel 建立加密隧道
- stunnel加密通道使用实践
- 使用加密的squid配合stunnel实现HTTP代理
- SSL双向认证的证书详解
- SSL使用windows证书库中证书实现双向认证
- stunnel客户端的使用
- 使用Java进行双向认证的SSL链接以及使用OpenSSL生产证书链
- 使用stunnel加密普通TCP连接
- https双向加密认证
- 使用CA签发的服务器证书搭建Tomcat双向SSL认证服务
- 相似图片搜索的原理
- C/C++的对象模型
- 本地计算机用plsql访问虚拟机中的oracle数据库
- noip2016 游记
- PAT B1021
- 使用stunnel双向证书认证加密samba的数据传输
- 1084. Broken Keyboard (20)解题报告
- Two Sum
- 初入开发组(3)--一个程序员的成长史(18)
- Jquery EasyUI dataGrid加载图片时,序号出现错行的解决办法
- [Leetcode]35. Search Insert Position
- Winform 使用SplashScreen窗口
- LibEvent中文帮助文档--第18章【LibEvent编程示例】
- AIDL学习总结