Skip to content

Instantly share code, notes, and snippets.

@Ruzzz
Created August 24, 2015 17:29
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 Ruzzz/9a772452c1bc919f7496 to your computer and use it in GitHub Desktop.
Save Ruzzz/9a772452c1bc919f7496 to your computer and use it in GitHub Desktop.
Prepare certificate with public key in PEM (text) or DER (binary) formats for Android /system/etc/security/cacerts
:: Contact: ruzzzua@gmail.com
:: Version: 2015.08.14
:: Dependencies: OpenSSL
@echo off
if "%1"=="" goto :USAGE
if "%1"=="-der" goto :DER
:PEM
for /f %%i in ('openssl x509 -in %1 -hash -noout') do set FILENAME=%%i.0
openssl x509 -in %1 > %FILENAME%
openssl x509 -in %1 -text -fingerprint -noout >> %FILENAME%
goto :eof
:DER
if "%2"=="" goto :USAGE
for /f %%i in ('openssl x509 -inform der -in %2 -hash -noout') do set FILENAME=%%i.0
openssl x509 -inform der -in %2 > %FILENAME%
openssl x509 -inform der -in %2 -text -fingerprint -noout >> %FILENAME%
goto :eof
:USAGE
echo Prepare certificate with public key in PEM (text) or DER (binary) formats
echo for Android /system/etc/security/cacerts
echo Usage: %~nx0 [-der] cert-file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment