blob: c68fe77af733ae8097653cd11b82e6a1701d2967 [file] [log] [blame]
Zhiyi Zhang915aa452020-10-17 17:20:58 -07001#!/usr/bin/env bash
2
3# Usage: ./step-1-root-ca.sh safebag-file-name password
4if [ "$#" -ne 2 ]; then
5 echo "Usage: $0 safebag-file-name password" >&2
6 exit 1
7fi
Zhiyi Zhang3aaf06d2020-10-17 13:05:36 -07008
Zhiyi Zhang633c5bf2020-10-17 16:28:05 -07009# file name and password to a safebag TODO
Zhiyi Zhang915aa452020-10-17 17:20:58 -070010SAFEBAG_FILE=$1
11PWD=$2
Zhiyi Zhangd6fa6f42020-10-17 16:17:26 -070012
Zhiyi Zhang3aaf06d2020-10-17 13:05:36 -070013# compile and install ndncert
14git clone https://github.com/Zhiyi-Zhang/ndncert.git
15cd ndncert
16git checkout origin/v0.3
17./waf configure
Zhiyi Zhang79ee9442020-10-17 15:35:56 -070018sudo ./waf install
19sudo cp ./build/systemd/ndncert-ca.service /etc/systemd/system/
Zhiyi Zhangd6fa6f42020-10-17 16:17:26 -070020sudo chmod 644 /etc/systemd/system/ndncert-ca.service
Zhiyi Zhang3aaf06d2020-10-17 13:05:36 -070021
Zhiyi Zhang79ee9442020-10-17 15:35:56 -070022# prepare the CA root key
23sudo mkdir /var/lib/ndncert-ca
24sudo chown ndn /var/lib/ndncert-ca
Zhiyi Zhang915aa452020-10-17 17:20:58 -070025sudo HOME=/var/lib/ndncert-ca -u ndn ndnsec-import -i $SAFEBAG_FILE -P $PWD
Zhiyi Zhang79ee9442020-10-17 15:35:56 -070026
27# prepare CA configuration file
Zhiyi Zhang3aaf06d2020-10-17 13:05:36 -070028echo -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 Zhang3aaf06d2020-10-17 13:05:36 -070030# run the CA
Zhiyi Zhangd6fa6f42020-10-17 16:17:26 -070031sudo systemctl start ndncert-ca
Zhiyi Zhang79ee9442020-10-17 15:35:56 -070032sleep(2)
Zhiyi Zhang3aaf06d2020-10-17 13:05:36 -070033
34# check the status to make sure everything is correct
Zhiyi Zhang915aa452020-10-17 17:20:58 -070035sudo systemctl status ndncert-ca