Skip to content

Instantly share code, notes, and snippets.

@kilfu0701
Last active June 3, 2020 23:34
Show Gist options
  • Save kilfu0701/8e0ee7e856d1960c7ff9 to your computer and use it in GitHub Desktop.
Save kilfu0701/8e0ee7e856d1960c7ff9 to your computer and use it in GitHub Desktop.
Extract certificates from Safari Extension. (MacOS 10.10.x)
## in command line
whereis xar
# > /usr/bin/xar
xar --version
# > xar 1.7dev
## check if there's '--extract-cert' option ?
xar -h
## if YES, run this commnad.
mkdir certs
xar -f my.safariextz --extract-certs certs
## if NO, build xar-1.6.1 from source code.
wget https://github.com/downloads/mackyle/xar/xar-1.6.1.tar.gz
tar zxvf xar-1.6.1.tar.gz
cd xar-1.6.1
./configure
make
sudo make install
# will install at /usr/local/bin/xar
mkdir certs
/usr/local/bin/xar -f my.safariextz --extract-certs certs
## if got error on compiling with 'lzma.h' not found,
## try install..
## "brew install xz"
## re-configure with...
## "./configure --with-lzma=/usr/local/Cellar/xz/5.2.0"
@customcommander
Copy link

Awesome ❤️

I'm running Mac OS X 10.10.4 and it looks like xar is available by default (or maybe after you've installed Xcode) but lacks the --extract-certs option (I have xar 1.7dev). I also needed to install xz as I was missing lzma.h (as you mentioned).

If you don't want to override the standard xar with an older version, you can define DESTDIR before running make install, e.g:

cd xar-1.6.1
./configure --with-lzma=/usr/local/Cellar/xz/5.2.1
make
make DESTDIR=/tmp install

The xar 1.6.1 will be available at /tmp/usr/local/bin/xar.

If you run that xar, you'll get this warning: xar: warning: linked xar library version older than xar executable which can be ignored.

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