Setup of .well-known/did.json
If you are choosing to use the did
Overview
The .well-known/did.json file connects your domain with a Decentralized Identifier (DID) and exposes the public key used to sign declarations. This enables verifiers to confirm that the same entity controls both the cryptographic key and the domain used in your Liccium declarations.
What is a DID Document?
A DID (Decentralized Identifier) document is a JSON-LD document that contains cryptographic keys and other metadata associated with a decentralized identifier. In the context of did:web, it enables domain-based identity verification and allows anyone to look up the key at a well-known location on your domain.
Prerequisites
To complete the setup, ensure you have:
- Your X.509 certificate in .p12 format
- openssl installed on your system
- Node.js and npm (for the key conversion script)
- Access to your domain's web server
Step-by-Step Setup
Step 1: Convert .p12 to .pem Certificate
Extract your certificate (with public key) from the .p12 container:
Code
Replace your_cert.p12 with your actual file. This creates a cert.pem file.
Step 2: Extract the RSA Public Key
Code
This creates a pubkey.pem file containing your RSA public key.
Step 3: Convert the Public Key to JWK Format (RSA)
Use node-jose to convert the PEM to JWK format:
JavaScript Script (Node.js)
Code
Install and Run:
Code
The output will contain a JWK like:
Code
Step 4: Generate the .well-known/did.json File
Create a JSON file at /.well-known/did.json using the extracted values:
Code
Important:
- Replace
yourdomain.comwith your actual domain name - Use the real
n,e, andx5t#S256values from your conversion
Step 5: Deploy the DID Document
Place the did.json file at:
Code
Your web server must:
- Serve the file over HTTPS
- Return
application/jsoncontent type - Respond to CORS requests if needed
Verification
After deployment, verify your setup by:
- Accessibility Check: Visit
https://yourdomain.com/.well-known/did.jsonin your browser - JSON Validation: Ensure the response is valid JSON
- CORS Headers: Verify that appropriate CORS headers are set if needed
- HTTPS: Confirm the file is served over HTTPS
Testing Your DID Document
Code
The response should be your DID document with proper JSON formatting.
Deployment Options
Web Server
Place the file in your web server's document root under the .well-known/ directory.
CDN/Static Hosting
Upload to your CDN or static hosting service ensuring proper MIME type (application/json).
Security Considerations
Critical Security Points:
- Never include private keys in the DID document
- Ensure the
.well-known/did.jsonfile is served over HTTPS - Keep the certificate and private key securely stored
Next Steps
Once your .well-known/did.json is deployed and verified:
- Use the corresponding private key to sign Liccium declarations
- Submit your declarations via the Liccium Declaration API
- Enable cryptographic verification of your declarations by third parties using your domain-bound DID