forked from demisto/content
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreateCerts.sh
More file actions
33 lines (22 loc) · 857 Bytes
/
createCerts.sh
File metadata and controls
33 lines (22 loc) · 857 Bytes
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
#!/bin/bash
# This script should run in the devcontainer.
# This script creates a local certificate file.
# It tries to connect to a server (for instance, github), show the local certificates and save it to a file.
# We connect to a random server and not paloaltonetworks.com to get external certificates.
# if command fails
if curl -I https://github.com > /dev/null; then
echo "No need to update certificate"
exit
fi
CONNECT_SERVER="github.com:443"
FILE=$1
REGEX_BEGIN="/^-----BEGIN CERTIFICATE-----$/"
REGEX_END="/^-----END CERTIFICATE-----$"
# Parse the certificate to a file
openssl s_client -showcerts -connect $CONNECT_SERVER | \
sed -n "$REGEX_BEGIN,$REGEX_END/p" > "$FILE"
if [ ! -f "$FILE" ]; then
echo "Failed getting the certificates, no output file was created."
exit
fi
git config --system http.sslCAInfo $FILE