blob: c399033f7e6c802108f7e53b922da5a85fb50459 [file] [log] [blame]
ktimoney28fa9fb2022-05-30 16:08:27 +01001#!/bin/sh
2#
3# ============LICENSE_START=======================================================
4# Copyright (C) 2022 Nordix Foundation.
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#
18# SPDX-License-Identifier: Apache-2.0
19# ============LICENSE_END=========================================================
20#
21
22
23CA_SUBJECT="/C=IE/ST=/L=/O=/OU=Keycloak/CN=localhost/emailAddress=ca@mail.com"
24SERVER_SUBJECT="/C=IE/ST=/L=/O=/OU=Keycloak/CN=localhost/emailAddress=server@mail.com"
25PW=changeit
26
27echo $PW > secretfile.txt
28
29openssl req -x509 -sha256 -days 3650 -newkey rsa:4096 -keyout rootCA.key -subj "$CA_SUBJECT" -passout file:secretfile.txt -out rootCA.crt
30
31openssl req -new -newkey rsa:4096 -keyout tls.key -subj "$SERVER_SUBJECT" -out tls.csr -nodes
32
33echo "authorityKeyIdentifier=keyid,issuer" > openssl.ext
34echo "basicConstraints=CA:FALSE" >> openssl.ext
35echo "subjectAltName = @alt_names" >> openssl.ext
36echo "[alt_names]" >> openssl.ext
37echo "DNS.1 = localhost" >> openssl.ext
38
39openssl x509 -req -CA rootCA.crt -CAkey rootCA.key -in tls.csr -passin file:secretfile.txt -out tls.crt -days 365 -CAcreateserial -ext openssl.ext
40
41rm secretfile.txt openssl.ext 2>/dev/null