-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathget-latest-bankid-test-certificates.sh
executable file
·39 lines (33 loc) · 1.54 KB
/
get-latest-bankid-test-certificates.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
# Test BankID Certificate Script
#
# !!!! FOR BANKID TEST ENVIRONMENT ONLY !!!!
#
# This script is not at all relevent for production or if you generate
# your own certificates via:
# https://www.bankid.com/utvecklare/guider/teknisk-integrationsguide/rp-introduktion
#
# This bash file will download the publically available SSL certificates.
# You will need to confirm the appropriate download url from:
# https://www.bankid.com/en/utvecklare/test
#
# You will also need the publically available passphase for the SSL certificate.
# The latest information can be found:
# https://www.bankid.com/assets/bankid/rp/bankid-relying-party-guidelines-v3.6.pdf
#
# To override the download URL simply copy the url after the password
# ./get-latest-bankid-certificates.sh https://www.bankid.com/assets/bankid/rp/FPTestcert3_20200618.p12
#
URL="${1:-https://www.bankid.com/assets/bankid/rp/FPTestcert3_20200618.p12}"
DOWNLOAD_FILE=test-bankid.p12
CODE_PATH=./code/bankid-auth
echo -n "Please enter the BankID Passphase: "
read -rs password
echo -e "\nPath for test certificate: \n ${URL}"
echo -e "Downloading p12 certificate to ${DOWNLOAD_FILE}"
curl "${URL}" --output ${DOWNLOAD_FILE}
echo -e "Unpacking test certificate into separate pem files"
openssl pkcs12 -info -nodes -in ${DOWNLOAD_FILE} -out ${CODE_PATH}/key.pem -nocerts -nodes -passin pass:"${password}"
openssl pkcs12 -info -nodes -in ${DOWNLOAD_FILE} -out ${CODE_PATH}/cert.pem -clcerts -nokeys -passin pass:"${password}"
echo -e "Deleting downloaded p12 certificate ${DOWNLOAD_FILE}"
rm ${DOWNLOAD_FILE}