Instrumental | 7a1817b | 2018-11-05 11:11:15 -0600 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | ######### |
| 3 | # ============LICENSE_START==================================================== |
| 4 | # org.onap.aaf |
| 5 | # =========================================================================== |
| 6 | # Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. |
| 7 | # =========================================================================== |
| 8 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 | # you may not use this file except in compliance with the License. |
| 10 | # You may obtain a copy of the License at |
Instrumental | 31d847e | 2018-03-26 14:17:19 -0700 | [diff] [blame] | 11 | # |
Instrumental | 7a1817b | 2018-11-05 11:11:15 -0600 | [diff] [blame] | 12 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | # |
| 14 | # Unless required by applicable law or agreed to in writing, software |
| 15 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | # See the License for the specific language governing permissions and |
| 18 | # limitations under the License. |
| 19 | # ============LICENSE_END==================================================== |
| 20 | ## |
Instrumental | 31d847e | 2018-03-26 14:17:19 -0700 | [diff] [blame] | 21 | # NOTE: This README is "bash" capable. bash README.txt |
| 22 | # |
| 23 | # create simple but reasonable directory structure |
| 24 | mkdir -p private certs newcerts |
| 25 | chmod 700 private |
| 26 | chmod 755 certs newcerts |
| 27 | touch index.txt |
| 28 | echo '01' > serial |
| 29 | |
| 30 | echo "IMPORTANT: If for any reason, you kill this process, type 'stty sane'" |
| 31 | echo "Enter the PassPhrase for your Key: " |
| 32 | `stty -echo` |
| 33 | #read PASSPHRASE |
| 34 | PASSPHRASE=HunkyDoryDickoryDock |
| 35 | `stty echo` |
| 36 | |
| 37 | # Create a regaular rsa encrypted key |
| 38 | openssl genrsa -aes256 -out private/ca.ekey -passout stdin 4096 << EOF |
| 39 | $PASSPHRASE |
| 40 | EOF |
| 41 | |
| 42 | # Move to a Java readable time, not this one is NOT Encrypted. |
| 43 | openssl pkcs8 -in private/ca.ekey -topk8 -nocrypt -out private/ca.key -passin stdin << EOF |
| 44 | $PASSPHRASE |
| 45 | EOF |
| 46 | chmod 400 private/ca.key private/ca.ekey |
| 47 | |
| 48 | # Generate a CA Certificate |
| 49 | openssl req -config openssl.conf \ |
| 50 | -key private/ca.key \ |
| 51 | -new -x509 -days 7300 -sha256 -extensions v3_ca \ |
| 52 | -out certs/ca.crt << EOF |
| 53 | $PASSPHRASE |
| 54 | EOF |
| 55 | |
| 56 | # All done, print result |
| 57 | openssl x509 -text -noout -in certs/ca.crt |