Update parameters for distribution CSIT
[policy/docker.git] / csit / gen_keystore.sh
1 #!/bin/bash
2 #
3 # ===========LICENSE_START====================================================
4 #  Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
5 # ============================================================================
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 #      http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 # ============LICENSE_END=====================================================
18 #
19
20 #
21 # Generates a self-signed keystore for use by the various policy docker
22 # images.
23 #
24
25 DIR="${0%/*}/config"
26 cd "${DIR}"
27
28 OUTFILE=ks.jks
29
30 ALIAS="policy@policy.onap.org"
31 PASS=Pol1cy_0nap
32
33 dn="C=US, O=ONAP, OU=OSAAF, OU=policy@policy.onap.org:DEV, CN=policy"
34
35 rm -f "${OUTFILE}"
36
37 keytool -genkeypair -alias "${ALIAS}" -validity 30 \
38     -keyalg RSA -dname "${dn}" -keystore "${OUTFILE}" \
39     -keypass "${PASS}" -storepass "${PASS}"
40
41 keytool -certreq -alias "${ALIAS}" -keystore ks.jks -file ks.csr \
42     -storepass "${PASS}"
43
44 openssl x509 -CA caroot.cer -CAkey cakey.pem -CAserial caserial.txt \
45     -req -in ks.csr -out ks.cer -passin "pass:${PASS}" \
46     -extfile dns_ssl.txt -days 30
47
48 keytool -import -noprompt -file caroot.cer -keystore ks.jks \
49     -storepass "${PASS}"
50
51 keytool -import -alias "${ALIAS}" -file ks.cer -keystore ks.jks \
52     -storepass "${PASS}"
53
54 chmod 644 "$OUTFILE"