iot lab work shop
This project is maintained by DanielYEHsieh
In this Lab, you will generate JITR approach 2 related configuration and test the follow of JITR approach 2.
aws configure
aws iot describe-endpoint
For IoT devices onboarding, JITR approach 2 offers a method that devices could generate device certificate and key automatically. Through IoT Core, rule engine and DynamoDB, it becomes more secure in management and more efficient in certificate/key rotation.
openssl genrsa -out CA_Private.key 2048
openssl req -x509 -new -nodes -key CA_Private.key -sha256 -days 365 -out CA_Certificate.pem
aws iot get-registration-code
openssl genrsa -out Verification_Private.key 2048
openssl req -new -key Verification_Private.key -out Verification.csr
openssl x509 -req -in Verification.csr -CA CA_Certificate.pem -CAkey CA_Private.key -CAcreateserial -out Verification.crt -days 365 -sha256
aws iot register-ca-certificate --ca-certificate file://CA_Certificate.pem --verification-certificate file://Verification.crt --set-as-active --allow-auto-registration
In this lab, we use device Wi-Fi MAC address as device serial number (DSN). To verify it, we need to create a database in AWS DynamoDB. When device generates the certificate and key, they will be used to connect to IoT core via MQTT over TLS. IoT Core will trigger rule engine and pass device information to a Lambda function. Lambda will verify this information with DynamoDB. If it is valid, Lambda function will create a thing name and policy for this device.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource": "arn:aws:logs:*:*:*"
},
{
"Effect": "Allow",
"Action": [
"iot:DetachThingPrincipal",
"iot:CreateThing",
"iot:DeleteThing",
"iot:DetachPolicy",
"iot:AttachThingPrincipal",
"iot:DeleteCertificate",
"iot:AttachPolicy",
"iot:AttachPrincipalPolicy",
"iot:DescribeThing",
"iot:CreatePolicy",
"iot:DescribeCertificate",
"iot:ListAttachedPolicies",
"iot:DeletePolicy",
"iot:ListPrincipalPolicies",
"iot:DetachPrincipalPolicy",
"iot:ListThingPrincipals",
"iot:UpdateCertificate",
"iot:ListThings",
"dynamodb:Scan",
"dynamodb:BatchGetItem",
"dynamodb:Query",
"dynamodb:List*",
"dynamodb:Describe*",
"dynamodb:GetItem"
],
"Resource": "*"
}
]
}
SELECT * FROM '$aws/events/certificates/registered/xxxxxxxxxxxxx'
git clone https://github.com/aws-tec/jitr-approach2.git
cmake -DVENDOR=espressif -DBOARD=esp32_devkitc -DCOMPILER=xtensa-esp32 -GNinja -S . -B build\
ninja
vendors\espressif\esp-idf\tools\idf.py erase_flash flash monitor -B build -p COM4