blob: 140927f73b71d0d6c58c5898f5659657d6976b83 [file] [log] [blame]
PatrikBuhrd1d08542020-09-11 16:50:37 +02001The keystore.jks and truststore.jks files are created by using the following commands (note that this is an example):
2
31) Create a CA certificate and a private key:
4
5openssl genrsa -des3 -out CA-key.pem 2048
6openssl req -new -key CA-key.pem -x509 -days 1000 -out CA-cert.pem
7
82) Create a keystore with a private key entry that is signed by the CA:
9
10keytool -genkeypair -alias policy_agent -keyalg RSA -keysize 2048 -keystore keystore.jks -validity 3650 -storepass policy_agent
11keytool -certreq -alias policy_agent -file request.csr -keystore keystore.jks -ext san=dns:your.domain.com -storepass policy_agent
12openssl x509 -req -days 365 -in request.csr -CA CA-cert.pem -CAkey CA-key.pem -CAcreateserial -out ca_signed-cert.pem
13keytool -importcert -alias ca_cert -file CA-cert.pem -keystore keystore.jks -trustcacerts -storepass policy_agent
14keytool -importcert -alias policy_agent -file ca_signed-cert.pem -keystore keystore.jks -trustcacerts -storepass policy_agent
15
16
173) Create a trust store containing the CA cert (to trust all certs signed by the CA):
18
19keytool -genkeypair -alias not_used -keyalg RSA -keysize 2048 -keystore truststore.jks -validity 3650 -storepass policy_agent
20keytool -importcert -alias ca_cert -file CA-cert.pem -keystore truststore.jks -trustcacerts -storepass policy_agent
21
22
234) Command for listing of the contents of jks files, examples:
24keytool -list -v -keystore keystore.jks -storepass policy_agent
25keytool -list -v -keystore truststore.jks -storepass policy_agent
26
27## License
28
29Copyright (C) 2020 Nordix Foundation. All rights reserved.
30Licensed under the Apache License, Version 2.0 (the "License");
31you may not use this file except in compliance with the License.
32You may obtain a copy of the License at
33
34 http://www.apache.org/licenses/LICENSE-2.0
35
36Unless required by applicable law or agreed to in writing, software
37distributed under the License is distributed on an "AS IS" BASIS,
38WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
39See the License for the specific language governing permissions and
40limitations under the License.
41