-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathadd_self-signed_cert_to_java_cacerts.sh
More file actions
executable file
·45 lines (38 loc) · 1.33 KB
/
add_self-signed_cert_to_java_cacerts.sh
File metadata and controls
executable file
·45 lines (38 loc) · 1.33 KB
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
40
41
42
43
44
45
#!/bin/sh
# ------------------------------------------------------------------------+
# This script adds a self-signed certificate to the Java cacerts keystore.|
# |
# Created by James Barclay (james@everythingisgray.com) on 2013-12-23 |
# ------------------------------------------------------------------------+
keytool="/usr/bin/keytool"
cert_path="/Library/Application Support/.CompanyName/Certificates/JavaDeploymentRuleSet"
cacerts_path="/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib/security/cacerts"
storepass="changeit"
log="/Library/Logs/cacerts_import.log"
# Redirection
exec >> $log 2>&1
if [ $EUID -ne 0 ]; then
echo "This script must run as root. Exiting now."
exit 1
fi
if [ -f "$cert_path/Cert.csr" ]; then
# Add self-signed certificate to
# the Oracle Java cacerts keystore
if [ -f "$cacerts_path" ]; then
$keytool \
-import \
-noprompt \
-storepass "$storepass" \
-alias selfsigned \
-keystore "$cacerts_path" \
-trustcacerts \
-file "$cert_path/Cert.csr"
else
echo "$cacerts_path does not exist!"
fi
else
echo "Could not find $cert_path/Cert.csr."
exit 1
fi
echo "`basename $0` success `date`"
exit 0