BuildingUsingGenericBuildsystem: spc+pvk-to-p12.sh

File spc+pvk-to-p12.sh, 592 bytes (added by Samuli Seppänen, 6 years ago)

Script from Alon Bar-Lev to convert .spc + .pvk files into a pkcs12 keystore

Line 
1#!/bin/sh
2#
3# Convert SPC+PVK to standard PKCS#12
4# Written by Alon Bar-Lev <alon.barlev@gmail.com>
5#
6
7spc="$1"
8pvk="$2"
9import_pass="$3"
10export_pass="$4"
11
12if [ -z "${export_pass}" ]; then
13        echo "usage: $0 spc pvk in-pass out-pass"
14        exit 1
15fi
16
17openssl rsa -in "${pvk}" -inform PVK -passin "pass:${import_pass}" -out my.rsa -passout "pass:${export_pass}"
18
19iconv -f UCS2 -t UTF8 "${spc}" | sed 's/\(...........\)/\1\n/g' | openssl enc -d -a | openssl pkcs7 -inform DER -print_certs | openssl pkcs12 -export -inkey my.rsa -passin "pass:${export_pass}" -out my.p12 -passout "pass:${export_pass}"