Skip to content

Instantly share code, notes, and snippets.

@peter279k
Last active October 19, 2020 09:35
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 peter279k/fd2af3428430bae9a15ca74e9547611f to your computer and use it in GitHub Desktop.
Save peter279k/fd2af3428430bae9a15ca74e9547611f to your computer and use it in GitHub Desktop.
This is importing certificate in Ubuntu 18.04 & 16.04
#!/bin/bash
# Reference: https://askubuntu.com/questions/73287/how-do-i-install-a-root-certificate
sudo_prefix=""
if [[ ${USER} != 'root' ]]; then
sudo_prefix="sudo "
fi;
cert_dir=$1
cert_file_path=$2
if [[ ${cert_dir} == '' ]]; then
echo "Please specify certificate directory name!"
exit 1;
fi;
if [[ ${cert_file_path} == '' ]]; then
echo "Please specify full certificate file path!"
exit 1;
fi;
read -p "Do your ${cert_file_path} is PEM file?[Y/n] " ans_pem
if [[ ${ans_pem} == 'Y' || ${ans_pem} == '' ]]; then
openssl x509 -in ${cert_file_path} -inform PEM -out "${cert_file_path}.crt"
cert_file_path="${cert_file_path}.crt"
fi;
${sudo_prefix}mkdir "/usr/share/ca-certificates/${cert_dir}"
${sudo_prefix}cp ${cert_file_name} "/usr/share/ca-certificates/${cert_dir}/${cert_file_name}"
${sudo_prefix}update-ca-certificates
@peter279k
Copy link
Author

Refresh Ubuntu GPG Key Error and the reference is as follows:

Example: R-Studio, the GPG Key error is invalid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment