openssl inside a chroot

烈酒焚心 提交于 2019-12-04 14:48:20

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

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

and the same for urandom.

You could fake random for openssl, e.g. command-line openssl:

[root@quilt /]# openssl s_client -h
usage: s_client args
...
 -rand file:file:...
...

Anyhow openssl needs a source of randomness, it cannot be secure without random nonce, e.g. from wikipedia:

In order to generate the session keys used for the secure connection, the client encrypts a random number with the server's public key and sends the result to the server. Only the server should be able to decrypt it, with its private key.

Without source of randomness, SSL/TLS can be easily hacked.

If you are worried that chroot/dev/ can be deleted, why not create only chroot/dev/random or chroot/dev/urandom intead of mounting whole dev?

[root@quilt /]# mknod /dev/random c 1 8
[root@quilt /]# mknod /dev/urandom c 1 9

Oh, btw you also want to copy system /etc/resolv.conf and possibly other hosts, services, ethers, etc...

Don't forgot about SELinux after create urandom and random

cat /var/log/messages | grep "SELinux is preventing"

SELinux is preventing /usr/sbin/php-fpm from read access on the chr_file urandom.

If you believe that php-fpm should be allowed read access on the urandom chr_file by default.
Then you should report this as a bug.
You can generate a local policy module to allow this access.
Do allow this access for now by executing:

ausearch -c 'php-fpm' --raw

audit2allow -M my-phpfpm

semodule -i my-phpfpm.pp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!