Zhiyi Zhang | 3aaf06d | 2020-10-17 13:05:36 -0700 | [diff] [blame] | 1 | #! /bin/bash |
| 2 | |
tylerliu | e0a7dd0 | 2020-10-17 17:10:59 -0700 | [diff] [blame^] | 3 | # Generate ndncert config file |
| 4 | echo 'Please enter the /ndn certificate:(end with Ctrl-D)' |
| 5 | ROOT_CERT=$(cat | tr -d '\n') |
| 6 | |
| 7 | cat > ndncert-site-client.conf << ~EOF |
| 8 | { |
| 9 | "ca-list": |
| 10 | [ |
| 11 | { |
| 12 | "ca-prefix": "/ndn", |
| 13 | "ca-info": "NDN Testbed Root Trust Anchor", |
| 14 | "max-validity-period": "1296000", |
| 15 | "max-suffix-length": "3", |
| 16 | "probe-parameters": |
| 17 | [ |
| 18 | {"probe-parameter-key": "pin"} |
| 19 | ], |
| 20 | "certificate": "$ROOT_CERT" |
| 21 | } |
| 22 | ] |
| 23 | } |
| 24 | ~EOF |
| 25 | |
| 26 | echo 'Please enter the /ndn certificate:(end with Ctrl-D)' |
| 27 | ROOT_CERT=$(cat | tr -d '\n') |
| 28 | |
| 29 | # compile and install ndncert |
| 30 | git clone https://github.com/Zhiyi-Zhang/ndncert.git |
| 31 | cd ndncert |
| 32 | git checkout origin/v0.3 |
| 33 | ./waf configure |
| 34 | sudo ./waf install |
| 35 | sudo cp ./build/systemd/ndncert-ca.service /etc/systemd/system/ |
| 36 | sudo chmod 644 /etc/systemd/system/ndncert-ca.service |
| 37 | |
| 38 | |
| 39 | |
| 40 | # prepare CA configuration file |
| 41 | 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 |
| 42 | |
| 43 | # run the CA |
| 44 | sudo systemctl start ndncert-ca |
| 45 | sleep(2) |
| 46 | |
| 47 | # check the status to make sure everything is correct |
| 48 | sudo systemctl status ndncert-server |
| 49 | |