Signing Authority
How-To Guide: Delegating Credential Issuance with Your Own AWS-Hosted Signing Authority
Welcome! This how-to guide will walk you through deploying, configuring, and using your own self-hosted "Signing Authority" on AWS. This allows a primary identity (the "Owner") to delegate the ability to sign and issue credentials to this AWS-hosted service, without exposing the Owner's primary private keys. It's a robust pattern for enhanced security and operational flexibility in a cloud environment.
What is a Signing Authority and Why Use It?
Imagine your organization (the Owner) wants to allow a specific department's application or a trusted partner service to issue "Course Completion" badges on its behalf. You wouldn't want to give that application your organization's main private key. Let's use a Signing Authority!
What you'll accomplish in this tutorial:
Deploy the
simple-signing-service
to AWS Lambda and API Gateway using the Serverless Framework (this will be your Signing Authority).Configure an "Owner" LearnCard instance that will delegate issuance.
Instruct your AWS-hosted Signing Authority (via its configuration) to be ready to sign for your Owner.
Register your AWS-hosted Signing Authority with the LearnCloud Network, linking it to your Owner's profile.
Create a "Boost" (credential template) as the Owner.
Issue an instance of this Boost to a recipient, with the signing performed by your AWS-hosted Signing Authority.
Prerequisites:
Node.js (v16+ recommended) and pnpm (or npm/yarn, but
simple-signing-service
uses pnpm for its scripts).Git installed.
AWS Account: An active AWS account with permissions to create IAM roles, Lambda functions, API Gateway, and SQS (if used by the service for async tasks, though
simple-signing-service
is primarily synchronous).AWS CLI Installed and Configured: With credentials and a default region set up. (e.g.,
aws configure
).Serverless Framework Installed:
npm install -g serverless
(orpnpm add -g serverless
).MongoDB Instance: A running MongoDB instance accessible from AWS (e.g., MongoDB Atlas free tier, or Amazon DocumentDB). You'll need its full connection URI.
Two Secure Seeds: You'll need two distinct, 64-character hexadecimal seed phrases:
One for the Owner profile.
One for your Simple Signing Service (this will be its master key, configured as an environment variable in AWS).
Remember: These must be cryptographically random and kept extremely secure.
Basic Understanding: Familiarity with Verifiable Credentials, DIDs, AWS Lambda, API Gateway, and the Create a Claimable Boost Quickstart.
LearnCard SDK Packages:
Part 1: Deploying the simple-signing-service
to AWS
simple-signing-service
to AWSThis service, once deployed on AWS, will act as your dedicated Signing Authority.
Step 1.1: Clone and Setup the Service
Step 1.2: Configure for AWS Deployment (serverless.yml
and Environment Variables)
serverless.yml
and Environment Variables)The simple-signing-service
is designed for serverless deployment. Key configurations are managed via serverless.yml
and environment variables.
Review
serverless.yml
: Open theserverless.yml
file in thesimple-signing-service
directory. Familiarize yourself with its structure. It defines the AWS Lambda function, API Gateway trigger, and expected environment variables.Set Environment Variables for Deployment:
For AWS deployment, environment variables should not be hardcoded in a .env file that gets committed. Instead, they should be configured securely for your Lambda function. You can do this via the environment section in serverless.yml (for values safe to commit, or using Serverless Framework's variable system like ${env:VAR_NAME} or ${ssm:/path/to/param} for secrets), or directly in the AWS Lambda console after deployment (less ideal for IaC).
For this guide, we'll focus on setting them in
serverless.yml
using environment variables you'll set in your terminal before deploying, or by directly editingserverless.yml
(for non-sensitive defaults).Modify serverless.yml (example for environment variables): Open serverless.yml and locate the provider.environment section. It might look something like this initially:
Before deploying, you will need to set these environment variables in your terminal, or replace
${env:VAR_NAME}
with actual values if you're not using terminal env vars for deployment.SIGNING_SERVICE_SEED
: Your unique, secure 64-character hex seed for this Signing Authority.AUTHORIZED_DIDS
: The DID of the "Owner" profile (you'll get this in Part 2). For initial deployment, you can set a placeholder like"did:key:zPlaceholderOwnerDID"
. You will need to update this environment variable and redeploy the Lambda function after obtaining the Owner's actual DID.MONGO_URI
: Your full MongoDB connection string (e.g., from MongoDB Atlas).MONGO_DB_NAME
: The name of your MongoDB database (e.g.,my_signing_service_db
).
Step 1.3: Deploy to AWS
Ensure your AWS CLI is configured with the correct account and region. Then, from the simple-signing-service
directory:
Set environment variables in your terminal (example):
Deploy using Serverless Framework:
Step 1.4: Obtain Your Deployed API Endpoint
After a successful deployment, the Serverless Framework output will show your API endpoint URL. It will look something like:
Note this URL. This is YOUR_AWS_SIGNING_AUTHORITY_ENDPOINT
.
Part 2: Setting Up the "Owner" LearnCard Instance
This script will represent the organization or individual who owns the credentials and wants to delegate their issuance. Create a new file (e.g., delegateIssuanceTutorial.ts
) in a separate project folder.
Action Required (Critical)
Run
setupOwnerLearnCard()
once (e.g., by calling it in yourmain
function and running the script).Copy the
Owner DID
printed to your console.Go to your
simple-signing-service
project. Update theAUTHORIZED_DIDS
environment variable for your Lambda function (either inserverless.yml
and redeploy, or directly in the Lambda console's environment variables section) to include this Owner's DID.Redeploy your
simple-signing-service
to AWS with the updated environment variable:pnpm serverless-deploy --stage dev --region your-region
.Once redeployed, you can proceed with the rest of the tutorial script.
Part 3: Registering Your AWS-Hosted Signing Authority with LearnCloud Network
The Owner informs the LearnCloud Network about their trust in your AWS-hosted Signing Authority.
Part 4: Creating a Boost (as Owner)
The Owner creates a Boost template. This is the same as in previous tutorials.
Part 5: Issuing the Boost via Your AWS-Hosted Signing Authority
The Owner requests to issue the Boost. The LearnCloud Network, knowing about the registered Signing Authority, will route the signing request to your AWS Lambda function.
Use that token to send the boost via Signing Authority over REST endpoint:
Part 6: Putting It All Together (Main Script)
Running the Tutorial
Deploy
simple-signing-service
to AWS (Part 1):Follow Step 1.1 to 1.4 carefully. Ensure you set the
SIGNING_SERVICE_SEED
,MONGO_URI
, andMONGO_DB_NAME
environment variables correctly for your Lambda function during deployment. Initially,AUTHORIZED_DIDS
can be a placeholder.Note down your deployed AWS API Gateway endpoint.
Prepare
delegateIssuanceTutorial.ts
(Part 2 script):Create a new project folder, install
@learncard/init
and@learncard/simple-signing-plugin
.Save the code from Parts 2-6 into
delegateIssuanceTutorial.ts
.Crucially, update the placeholder constants at the top of the script:
OWNER_SEED
with a unique 64-char hex seed for the Owner.YOUR_AWS_SIGNING_AUTHORITY_ENDPOINT
with the actual endpoint from your AWS deployment.In the
main
function, updatesaSeedFromAwsEnv
with the exact same seed you configured for your AWS Lambda'sSIGNING_SERVICE_SEED
environment variable.Update
recipientProfileId
with a real Profile ID you can check.
First Run of
delegateIssuanceTutorial.ts
(to get Owner DID):Run
npx ts-node delegateIssuanceTutorial.ts
.The script will initialize
learnCardOwner
and print its DID. It will then pause, prompting you to update the AWS Lambda environment.
Update AWS Lambda Environment for
simple-signing-service
:Go to the AWS Lambda console, find your deployed
simple-signing-service
function.Under "Configuration" -> "Environment variables," edit
AUTHORIZED_DIDS
. Add the Owner's DID that was just printed by your script. If there are other DIDs, separate them with a space.Save the Lambda environment variable changes. (This change takes effect immediately, no full redeploy needed for just env var changes via console, but a
sls deploy
is cleaner if you changeserverless.yml
).
Continue
delegateIssuanceTutorial.ts
:Go back to the terminal running
delegateIssuanceTutorial.ts
and press Enter.The script will now attempt the remaining steps.
Verification & What Happened
AWS CloudWatch Logs: Monitor the CloudWatch Logs for your
simple-signing-service
Lambda function. When Part 5 of the tutorial runs (sendBoostViaAwsAuthority
), you should see logs from your Lambda indicating it received a request from the LearnCloud Network and performed a signing operation. This is the key confirmation that delegation is working through AWS.delegateIssuanceTutorial.ts
Console: Look for success messages. Any errors here or in CloudWatch will help debug.Recipient's LearnCard App: If you used a real
recipientProfileId
, they should receive the "Community Contributor Badge (AWS Delegated)". Inspecting this credential will show it's issued by the Owner's DID, but the proof section will reference the key/DID of your AWS-hosted Signing Authority.
Next Steps & Production Considerations
Security for AWS:
Manage the
SIGNING_SERVICE_SEED
andMONGO_URI
for your Lambda using secure methods like AWS Secrets Manager or Systems Manager Parameter Store, referenced in yourserverless.yml
, rather than plain text environment variables if possible.Configure appropriate IAM roles and permissions for your Lambda function, granting only necessary access (e.g., to MongoDB).
Secure your API Gateway endpoint (e.g., with API Keys, IAM authorization, or custom authorizers if needed beyond LCN's calls).
AUTHORIZED_DIDS
on AWS: Manage this list carefully.Error Handling & Logging: Implement comprehensive logging in your AWS Lambda for easier debugging.
Cost & Scalability: Be mindful of AWS Lambda, API Gateway, and any database costs. Design for scalability if you expect high volumes.
This tutorial provides a robust foundation for implementing delegated credential issuance using a self-hosted Signing Authority on AWS, enhancing the security and flexibility of your LearnCard solutions!
Last updated
Was this helpful?