Skip to content

Instantly share code, notes, and snippets.

@cassettesgoboom
Forked from 1stvamp/mac-curl-ca-bundle.sh
Last active November 1, 2021 21:41
Show Gist options
  • Select an option

  • Save cassettesgoboom/3c79f0bf0d97a2340102d239403f4762 to your computer and use it in GitHub Desktop.

Select an option

Save cassettesgoboom/3c79f0bf0d97a2340102d239403f4762 to your computer and use it in GitHub Desktop.
Script to install cURL CA certificates on OS X without macports
#!/bin/bash
# Author: Ronny Wing - 1st November 2021 - https://gist.github.com/cassettesgoboom/3c79f0bf0d97a2340102d239403f4762
# Original: 1stvamp - 22nd March 2012 - https://gist.github.com/1stvamp/2158128
echo
echo "Making working folder..."
mkdir /tmp/curl-ca-bundle
cd /tmp/curl-ca-bundle
echo
echo "Fetching latest curl.haxx.se package..."
latestCurl=$(curl -s -k https://curl.se/download/ | grep bz2 | grep -m1 href | cut -d '"' -f4)
wget "https://curl.haxx.se/$latestCurl"
echo
echo "Extracting..."
tar xzf curl*.tar.bz2
cd curl*/lib/
echo
echo "Building CA Bundled Certificate..."
./mk-ca-bundle.pl
echo
echo "Splitting Bundle and adding new CA Certificates to Keychain..."
mkdir -p ./splitcerts
cat ca-bundle.crt | (cd ./splitcerts && split -p '-----BEGIN CERTIFICATE-----' - cert- )
echo
echo "Please enter User Password for sudo Administration Rights..."
for cert in ./splitcerts/cert-* ; do
sudo security -v add-trusted-cert -d -r trustRoot -k "/Library/Keychains/System.keychain" "$cert"
done
echo
echo "Cleaning up..."
rm -r /tmp/curl-ca-bundle
echo
echo "Done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment