linux下添加自签名根证书的脚本

来源:互联网 发布:linux命令echo使用简介 编辑:程序博客网 时间:2024/05/01 08:23


#!/bin/shusage() {    ex="${1:-0}"    echo "Usage: $0 <host> [<port>]"    echo "\n\tPort will be set to 443 by default"    exit $ex}host="$1"if [ -z $host ] ; then    usage 1fiport="${2:-443}"ssl=/usr/bin/opensslcu=/usr/bin/certutiltmp="$(tempfile)"trap 'rm $tmp' 1 2 3 15echo |    openssl s_client -connect $host:$port 2>&1 |    sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > $tmpcertutil -d sql:$HOME/.pki/nssdb -A -t CP,,C -n "$host" -i $tmprm $tmp


原创粉丝点击