Skip to content

Instantly share code, notes, and snippets.

@icarrr
Created December 4, 2019 03:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icarrr/7dbfeebd60fca93ed030018f5ca25fd4 to your computer and use it in GitHub Desktop.
Save icarrr/7dbfeebd60fca93ed030018f5ca25fd4 to your computer and use it in GitHub Desktop.
Auto reset cert linux
#!/bin/bash
globalTime="$(date '+%Y%m%d %H%M%S' -d "$(curl -s --head http://google.com | grep ^Date: | sed 's/Date: //g')" | awk '{print $2}')"
if [ $globalTime == "060001" ]; then
$HOME/reset_cert.sh
fi
# Get time
localTime=$(date '+%Y%m%d_%H%M%S' -d "$(curl -s --head http://google.com | grep ^Date: | sed 's/Date: //g')")
# Create cert bak dir
mkdir -p $HOME/cert.bak
# Reset cert
rpm -Vv ca-certificates | awk '$1!="........." && $2!="d" {system("mv -v " $NF " $HOME/cert.bak")}'
yum check-update ca-certificates; (($?==100)) && yum update ca-certificates || yum reinstall -y ca-certificates
find /etc/pki/ca-trust/source{,/anchors} -maxdepth 1 -not -type d -exec ls -1 {} +
update-ca-trust extract
# Update locate cert bak
mv $HOME/cert.bak $HOME/cert/cert.bak-$localTime
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment