Last active
October 19, 2020 09:35
-
-
Save peter279k/fd2af3428430bae9a15ca74e9547611f to your computer and use it in GitHub Desktop.
This is importing certificate in Ubuntu 18.04 & 16.04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Refresh Ubuntu GPG Key Error and the reference is as follows:
Example: R-Studio, the GPG Key error is invalid.