A1PMS README style check
[nonrtric/plt/a1policymanagementservice.git] / config / README.md
1 # Keystore and Truststore Setup Guide
2
3 This guide provides step-by-step instructions for creating `keystore.jks` and `truststore.jks` files. Follow the commands carefully to ensure proper setup.
4
5 ## 1. Create a CA Certificate and Private Key
6
7 Generate a CA private key and self-signed certificate:
8
9 ```sh
10 openssl genrsa -des3 -out CA-key.pem 2048
11 openssl req -new -key CA-key.pem -x509 -days 3600 -out CA-cert.pem
12 ```
13
14 ## 2. Create a keystore with a private key entry that is signed by the CA:
15
16 Note: the "your name" must be "localhost" for the unittest to work.
17
18 ```sh
19 keytool -genkeypair -alias policy_agent -keyalg RSA -keysize 2048 -keystore keystore.jks -validity 3650 -storepass policy_agent
20 keytool -certreq -alias policy_agent -file request.csr -keystore keystore.jks -ext san=dns:your.domain.com -storepass policy_agent
21 openssl x509 -req -days 3650 -in request.csr -CA CA-cert.pem -CAkey CA-key.pem -CAcreateserial -out ca_signed-cert.pem
22 keytool -importcert -alias ca_cert -file CA-cert.pem -keystore keystore.jks -trustcacerts -storepass policy_agent
23 keytool -importcert -alias policy_agent -file ca_signed-cert.pem -keystore keystore.jks -trustcacerts -storepass policy_agent
24 ```
25
26 ## 3. Create a trust store containing the CA cert (to trust all certs signed by the CA):
27
28 ```sh
29 keytool -genkeypair -alias not_used -keyalg RSA -keysize 2048 -keystore truststore.jks -validity 3650 -storepass policy_agent
30 keytool -importcert -alias ca_cert -file CA-cert.pem -keystore truststore.jks -trustcacerts -storepass policy_agent
31 ```
32
33 ## 4. Command for listing of the contents of jks files, examples:
34
35 ```sh
36 keytool -list -v -keystore keystore.jks -storepass policy_agent
37 keytool -list -v -keystore truststore.jks -storepass policy_agent
38 ```
39
40 ## License
41
42 ONAP : ccsdk oran
43 Copyright (C) 2020-2023 Nordix Foundation. All rights reserved.
44 Licensed under the Apache License, Version 2.0 (the "License");
45 you may not use this file except in compliance with the License.
46 You may obtain a copy of the License at
47
48      http://www.apache.org/licenses/LICENSE-2.0
49
50 Unless required by applicable law or agreed to in writing, software
51 distributed under the License is distributed on an "AS IS" BASIS,
52 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
53 See the License for the specific language governing permissions and
54 limitations under the License.
55