chroot内的openssl [英] openssl inside a chroot

查看:186
本文介绍了chroot内的openssl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试从chroot监狱建立ssl连接时出现以下错误:

I'm getting the following error when I try to make an ssl connection from inside a chroot jail:

twisted.internet.error.ConnectionLost: Connection to the other side was lost in a non-clean fashion.

我正在将openssl 0.9.6与pyopenssl进行ssl连接,并且在Linux(centos 5.5)上使用了用于python 2.4的扭曲python库.

I'm using the openssl 0.9.6 with pyopenssl to make the ssl connection and I'm using the twisted python library for python 2.4 on Linux (centos 5.5).

经过一些故障排除后,我发现openssl失败,因为它试图读取/dev/random文件,并且失败了,因为chroot中没有/dev/random.我已经确认,如果我在chroot中创建一个/dev/random文件,则连接成功.

After some troubleshooting I've discovered that openssl is failing because it is trying to read the /dev/random file and it is failing because there is no /dev/random inside the chroot. I've confirmed that if I create a /dev/random file inside the chroot the connection succeeds.

  • 我曾考虑过安装devfs文件系统,该文件系统在chroot中包含/dev/random文件,但是我的应用程序和sysadmins习惯于删除chroot的根目录而不先卸载所有东西.
  • 我考虑过在执行chroot之前先读取/dev/random文件,但当前的设置是在二进制文件启动之前就调用chroot,更改chroot发生的位置将是一个很大的改变在应用程序中,我不确定何时或如何完成该操作.
  • 我曾考虑过在chroot监狱外运行一个程序,该程序仅从/dev/random中读取并写入名为/jail/dev/random的命名文件管道中,但可以从chroot监狱中访问该程序,但我不知道就像必须为了访问随机性源而运行一个单独的过程.仅仅初始化openssl似乎也太复杂了.

如果我无法从程序访问/dev/random,那么初始化openssl的正确方法是什么?

What is the right way to initialize openssl if I don't have access to /dev/random from my program?

推荐答案

也许更好的方法是按以下方式绑定安装设备文件:

Perhaps a better way is to bind-mount the device files as follows:

# touch chroot/dev/random
# mount --bind /dev/random chroot/dev/random

与urandom相同.

and the same for urandom.

这篇关于chroot内的openssl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆