[步骤] Linux 全局加密 SSL 的设置 (CentOS Linux 8 & RHEL 8 版)

步骤一:显示当前 SSL 全局加密 SSL 的状况

# update-crypto-policies --show
DEFAULT

(补充:这里的 DEFAULT 表示可以使用 2048 位及以上位数的 SSL)

步骤二:切换当前 SSL 全局加密 SSL

# update-crypto-policies --set FUTURE


补充:
1) 这里以将全局加密 SSL 切换到 FUTURE 状态为例
2) 此时只能使用 4096 位及以上位数的 SSL

[命令] Linux 命令 curl (测试网页访问)

内容一:测试网页可以被访问的案例

# curl -v -k https://eternalcenter.com

(补充:这里以直接访问 https://eternalcenter.com 网页为例)

内容二:测试网页访问速度的案例

2.1 案例一:显示测试过程

# curl -o /dev/null -s -w %{http_code}:%{http_connect}:%{content_type}:%{time_namelookup}:%{time_redirect}:%{time_pretransfer}:%{time_connect}:%{time_starttransfer}:%{time_total}:%{speed_download} https://eternalcenter.com

(补充:这里以访问并测试 https://eternalcenter.com,并显示测试过程为例)

2.2 案例二:不显示测试过程

# curl -o /dev/null -w %{http_code}:%{http_connect}:%{content_type}:%{time_namelookup}:%{time_redirect}:%{time_pretransfer}:%{time_connect}:%{time_starttransfer}:%{time_total}:%{speed_download} https://
eternalcenter.com

(补充:这里以访问并测试 https://eternalcenter.com,并不显示测试过程为例)

内容三:测试使用代理访问网页的案例

3.1 案例一:使用代理

# curl -v --proxy proxy.example.com:8080 https://eternalcenter.com

(补充:这里以通过 proxy.example.com:8080 代理访问 https://eternalcenter.com 网页为例)

3.2 案例二:使用代理并使用用户进行验证

# curl -v --<proxy user> user:<password> --proxy proxy.example.com:8080 https://eternalcenter.com

(补充:这里以通过 proxy.example.com:8080 代理并使用 proxy user 和 password 进行验证访问 https://eternalcenter.com 网页为例)

内容四: 测试使用证书访问网页的案例

# curl -v -k https://eternalcenter.com --cacert /eternalcenter.com.pem

(补充:这里以通过 eternalcenter.com.pem 证书访问 https://eternalcenter.com 网页为例)

内容五:其他测试访问网页的案例

5.1 案例一:将网页下载后另存为别的文件

# curl -v https://eternalcenter.com -o eternalcentre.com

(补充:这里以下载 https://eternalcenter.com 并另存为 eternalcentre.com 为例)

5.2 案例二:静默下载的案例

# curl -v https://eternalcenter.com -o eternalcentre.com --silent

(补充:这里以静默下载 https://eternalcenter.com 为例)

5.3 案例三:不使用安全证书访问网页

# curl -k https://eternalcenter.com

或者:

# curl https://eternalcenter.com --insecure

(补充:这里以不使用安全证书访问 https://eternalcenter.com 网页为例)

5.4 案例四:显示连接时的握手过程

# curl -vvvv -k https://eternalcenter.com

(补充:这里显示连接 https://eternalcenter.com 时的握手过程为例)

[步骤] SELinux 的启用 (openSUSE & SLES 版) (不建议)

软件准备:

在 SELinuxProject 的官网上下载 SELinux 策略 UseRefpolicy:

https://github.com/SELinuxProject/refpolicy/wiki/UseRefpolicy

注意:

1) 如果使用此文的方法将 openSUSE & SLE 的 SELinux 设置为 Enforcing 则系统将无法设置 IP 地址
2) 如果使用此文的方法开启了 SELinux 并且将所有的布尔(boolean)值开启,则系统将无法关机,开启所有布尔值的方法:# for i in semanage boolean -l | awk '{print $1}'; do echo $i;setsebool -P $i 1; done

正文:

步骤一:安装 SELinux 组件

# zypper in libselinux1 libsemanage1 libsepol-devel libsepol1 libselinux-devel mcstrans libselinux1-32bit policycoreutils checkpolicy libsemanage-devel setools-tcl setools-libs setools-java setools-devel setools-console selinux-tools python3-policycoreutils python3-selinux python3-semanage python3-setools restorecond

步骤二:安装 SELinux 策略

2.1 解压包含 SELinux 策略的压缩包

# tar -xvf refpolicy-2.20210203.tar.bz2

(补充:这里以解压 refpolicy-2.20210203.tar.bz2 压缩包为例)

2.2 将 SELinux 策略移动到 SELinux 配置文件的位置

# mv refpolicy /etc/selinux/

2.3 进入到和 SELinux 策略相同目录下

# cd /etc/selinux/refpolicy/

2.4 显示 SELinux 策略的安装手册

# cat INSTALL

2.5 创建 SELinux 策略的配置文件

# make conf

2.6 创建 SELinux 策略

# make policy

2.7 编译 SELinux 策略

# make install

2.8 安装 SELinux 策略

# make load

步骤三:配置 SELinux 配置文件

3.1 在 SELinux 配置文件中将 SELinux 设置为 Permissive 状态

# vim /etc/selinux/config

创建以下内容:

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=permissive
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=refpolicy

3.2 在系统内核中禁止使用 AppArmor 使用 SELinux 并且将 SELinux 状态设置为 Permissive

3.2.1 设置 /etc/default/grub 配置文件
# vim /etc/default/grub

在这一行里:

GRUB_CMDLINE_LINUX_DEFAULT="......"
添加以下内容:
GRUB_CMDLINE_LINUX_DEFAULT="...... security=selinux selinux=1 enforcing=0"
3.2.2 让刚刚设置的 /etc/default/grub 配置文件生效
# grub2-mkconfig -o /boot/grub2/grub.cfg

3.3 刷新系统内所有文件的标签

# restorecon -Rp /

步骤四:重启系统让 SELinux 生效

# reboot

参考文献:

https://documentation.suse.com/sles/15-SP2/html/SLES-all/cha-selinux.html