Zhiyi Zhang | 915aa45 | 2020-10-17 17:20:58 -0700 | [diff] [blame^] | 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | # Usage: ./step-1-root-ca.sh safebag-file-name password |
| 4 | if [ "$#" -ne 2 ]; then |
| 5 | echo "Usage: $0 safebag-file-name password" >&2 |
| 6 | exit 1 |
| 7 | fi |
Zhiyi Zhang | 3aaf06d | 2020-10-17 13:05:36 -0700 | [diff] [blame] | 8 | |
Zhiyi Zhang | 633c5bf | 2020-10-17 16:28:05 -0700 | [diff] [blame] | 9 | # file name and password to a safebag TODO |
Zhiyi Zhang | 915aa45 | 2020-10-17 17:20:58 -0700 | [diff] [blame^] | 10 | SAFEBAG_FILE=$1 |
| 11 | PWD=$2 |
Zhiyi Zhang | d6fa6f4 | 2020-10-17 16:17:26 -0700 | [diff] [blame] | 12 | |
Zhiyi Zhang | 3aaf06d | 2020-10-17 13:05:36 -0700 | [diff] [blame] | 13 | # compile and install ndncert |
| 14 | git clone https://github.com/Zhiyi-Zhang/ndncert.git |
| 15 | cd ndncert |
| 16 | git checkout origin/v0.3 |
| 17 | ./waf configure |
Zhiyi Zhang | 79ee944 | 2020-10-17 15:35:56 -0700 | [diff] [blame] | 18 | sudo ./waf install |
| 19 | sudo cp ./build/systemd/ndncert-ca.service /etc/systemd/system/ |
Zhiyi Zhang | d6fa6f4 | 2020-10-17 16:17:26 -0700 | [diff] [blame] | 20 | sudo chmod 644 /etc/systemd/system/ndncert-ca.service |
Zhiyi Zhang | 3aaf06d | 2020-10-17 13:05:36 -0700 | [diff] [blame] | 21 | |
Zhiyi Zhang | 79ee944 | 2020-10-17 15:35:56 -0700 | [diff] [blame] | 22 | # prepare the CA root key |
| 23 | sudo mkdir /var/lib/ndncert-ca |
| 24 | sudo chown ndn /var/lib/ndncert-ca |
Zhiyi Zhang | 915aa45 | 2020-10-17 17:20:58 -0700 | [diff] [blame^] | 25 | sudo HOME=/var/lib/ndncert-ca -u ndn ndnsec-import -i $SAFEBAG_FILE -P $PWD |
Zhiyi Zhang | 79ee944 | 2020-10-17 15:35:56 -0700 | [diff] [blame] | 26 | |
| 27 | # prepare CA configuration file |
Zhiyi Zhang | 3aaf06d | 2020-10-17 13:05:36 -0700 | [diff] [blame] | 28 | echo -e "{\n\"ca-prefix\": \"/ndn\",\n\"ca-info\": \"NDN testbed root CA\",\n\"max-validity-period\": \"1296000\",\n\"max-suffix-length\": \"2\",\n\"supported-challenges\":\n[\n{ \"challenge\": \"pin\" }\n]\n}" > /usr/local/etc/ndncert/ca.conf |
| 29 | |
Zhiyi Zhang | 3aaf06d | 2020-10-17 13:05:36 -0700 | [diff] [blame] | 30 | # run the CA |
Zhiyi Zhang | d6fa6f4 | 2020-10-17 16:17:26 -0700 | [diff] [blame] | 31 | sudo systemctl start ndncert-ca |
Zhiyi Zhang | 79ee944 | 2020-10-17 15:35:56 -0700 | [diff] [blame] | 32 | sleep(2) |
Zhiyi Zhang | 3aaf06d | 2020-10-17 13:05:36 -0700 | [diff] [blame] | 33 | |
| 34 | # check the status to make sure everything is correct |
Zhiyi Zhang | 915aa45 | 2020-10-17 17:20:58 -0700 | [diff] [blame^] | 35 | sudo systemctl status ndncert-ca |