Chore: Add gerrit maven verify GHA workflow
[sdnc/oam.git] / csit / plans / sdnc / generate_certs.sh
1 #!/bin/bash
2 #
3 # Copyright (c) 2022 highstreet technologies GmbH Property
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #     http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #
17 # generates fresh certificates for netconfserver
18
19
20 tls_dir=$1
21
22 cd $tls_dir
23 echo "generate all required certificates and store in $tls_dir"
24 openssl version
25 openssl req -newkey rsa:4096 -keyform PEM -keyout ca.key -x509 -days 3650 -outform PEM -out ca.crt -nodes \
26     -subj "/C=DE/ST=Berlin/L=Berlin/O=ONAP/OU=SDNC/CN=www.onap.org/emailAddress=dev@www.example.com"
27 openssl genrsa -out client.key 4096
28 openssl req -new -key client.key -out client.req -nodes \
29     -subj "/C=PL/ST=DS/L=Wroclaw/O=ONAP/OU=SDNC/CN=www.onap.org"
30 openssl x509 -req -in client.req -CA ca.crt -CAkey ca.key -set_serial 101 -extensions client -days 365 -outform PEM -out client.crt
31 openssl genrsa -out server_key.pem 4096
32 openssl req -new -key server_key.pem -out server.req -sha256 -nodes \
33     -subj "/C=PL/ST=DS/L=Wroclaw/O=ONAP/OU=SDNC/CN=www.onap.org"
34 openssl x509 -req -in server.req -CA ca.crt -CAkey ca.key -set_serial 100 -extensions server -days 1460 -outform PEM -out server_cert.crt -sha256
35