为了撤销对客户的访问,我可以做
$./revoke-full client_name
然后将新的crl.pem放在服务器中。
但是,如何重新启用该客户端? 删除crl.pem文件不是一个解决scheme,因为这将打破easy-keys目录,我将不能再次撤消它们。
证书不应该被解除! 你应该生成一个新的,并把它给客户端。
…但是,如果你愿意,
在您的CA文件夹中,应该有一个index.txt,其中包含证书标识。 以“V”开始的是有效的,“R”的是撤销的。 您可以编辑该文件,并将第一个字符修复为“V”,并删除第三列(撤销date)。 如果你有多个证书,你应该看到模式(序列号现在在第三列,等等)。
那么你只需要重新生成CRL,它应该工作。
这是一个丑陋的黑客,…我仍然build议为客户端生成一个新的证书。
虽然撤销切换是一个不太好的做法,但是还有一些特殊情况, 撤销密钥(如撤消 )可能是有用的。
最差的:一个crt 永远不能被删除,而不是像学习这样的非常具体的案例。 在这之后,你可能会看到我如何删除最后一个索引条目(作为撤销操作)。
有一个我写的一个小的unrevoke脚本。
由于这不是标准function,我添加了一种名为unrevoke.txt的日志文件,以ASCII格式重新使用index.txt (tab分隔)的结构:
U | Revocation date | Unrevocation date | Id | unknown | Subject
警告:它适用于我的需求,但你必须在正常使用前testing它们!
#!/bin/bash # un-revoke a certificate, regenerate CRL, # and verify revocation status CRL=crl.pem if test $# -ne 1; then echo "usage: unrevoke <name|idx>"; exit 1 fi if test $KEY_DIR; then cd $KEY_DIR read issuer < <(openssl x509 -issuer -noout -in $KEY_DIR/ca.crt) issuer=${issuer#*CN=} issuer=${issuer%%/*} export KEY_CN=$issuer KEY_OU=$issuer KEY_NAME=$issuer if [ -f $1.crt ] ;then NAM=$1 REV=($(sed -ne <index.txt "s/^R\t[^\t]*\t\([0-9]\+Z\)\t\([0-9A-F]\{2,8\}\)\tunknown\t\(.*CN=$1\/.*\)$/\1 \2 \3/p")) IDX=${REV[1]} SUB="${REV[@]:2}" else if [ -f $1.pem ] ;then IDX=$1 REV=($(sed -ne <index.txt "s/^R\t[^\t]*\t\([0-9]\+Z\)\t$1\tunknown\t\(.*CN=\([^\/]\+\)\/.*\)$/\1 \3 \2/p")) NAM=${REV[1]} SUB="${REV[@]:2}" fi fi CRT=$IDX.pem if [ -f $CRT ] && [ "$NAM" ] && [ "$IDX" ] ;then printf "Key idx: %s, name: %s\n" $IDX $NAM else echo Key $1 not found. exit 1 fi DTE=$(date +"%y%m%d%H%M%SZ") # unrevoke key sed -e "s/^R\t\([0-9]\+Z\)\t[0-9]\+Z\t$IDX\t/V\t\1\t\t$IDX\t/" -i.old index.txt && printf "U\t%s\t%s\t%s\tunknown\t%s\n" $REV $DTE $IDX "$SUB" >>unrevoke.txt # generate a new CRL openssl ca -gencrl -out $CRL -config $KEY_CONFIG # verify the revocation openssl verify -CAfile <(cat ca.crt $CRL) -crl_check $CRT else echo you must define KEY_DIR fi
仅供参考! :为了不被删除,以便允许他的撤销钥匙!
#!/bin/bash # For info only!! # key as to NEVER be deleted # for making a correct revocation liste # # Don't use it unless you're sure you know what you're doing!!! cd $KEY_DIR || exit 1 mapfile index <index.txt OIFS="$IFS" IFS=$'\t' line=(${index[${#index[@]}-1]}) IFS="$OIFS" if [ "$line" == "V" ] ;then idx=${line[2]} nam=${line[4]#*CN=} else idx=${line[3]} nam=${line[5]#*CN=} fi nam=${nam%%/*} rm -v $nam.* $idx.* unset index[${#index[@]}-1] cat index.txt >index.txt.old printf "%s" "${index[@]}" >index.txt cat serial >serial.old echo ${line[2]} >serial