1#!/usr/local/bin/bash
2# Copyright (c) 2012 The libmumble Developers
3# The use of this source code is goverened by a BSD-style
4# license that can be found in the LICENSE-file.
5
6shopt -s expand_aliases
7
8# Generate test fixtures from the source file, '*.google.dk-chain.pem'.
9# This file was generated by visting www.google.dk in Google Chrome on Linux
10# on 29-12-2012. The file was exported as 'Base64-encoded ASCII, certificate chain'.
11
12# Generate PKCS12 file for testing X509Certificate::FromPKCS12
13echo "" | openssl pkcs12 -export -nodes -nokeys -password stdin -out wildcard-google.dk-chain.p12 -in wildcard-google.dk-chain.pem
14
15# Generate PKCS12 file with password 'password' for testing X509Certificate::FromPKCS12
16echo "password" | openssl pkcs12 -export -nodes -nokeys -password stdin -out wildcard-google.dk-chain-password.p12 -in wildcard-google.dk-chain.pem
17
18# Generate DER for leaf cert to test regular import, as well as other per-cert methods.
19openssl x509 -in wildcard-google.dk-chain.pem -inform PEM -out wildcard-google.dk-leaf.crt -outform DER
20
21# Generate SHA1 and SHA256 digests for leaf
22cat wildcard-google.dk-leaf.crt | openssl sha -sha1 -binary > wildcard-google.dk-leaf.sha1
23cat wildcard-google.dk-leaf.crt | openssl sha -sha256 -binary > wildcard-google.dk-leaf.sha256
24
25# Extract notBefore and notAfter dates
26alias mumble_tconv="python -c \"import sys; import time; import calendar; sys.stdout.write(str(int(calendar.timegm(time.strptime(sys.stdin.read()[:-1], '%b %d %H:%M:%S %Y %Z')))))\""
27openssl x509 -in wildcard-google.dk-leaf.crt -inform DER -noout -startdate | sed 's,notBefore=,,' | mumble_tconv > wildcard-google.dk-leaf.notBefore
28openssl x509 -in wildcard-google.dk-leaf.crt -inform DER -noout -enddate | sed 's,notAfter=,,' | mumble_tconv > wildcard-google.dk-leaf.notAfter
29