Skip to content

Commit

Permalink
feat: use DNS in X.509 certificate
Browse files Browse the repository at this point in the history
Signed-off-by: Berend Sliedrecht <[email protected]>
  • Loading branch information
Berend Sliedrecht authored and berendsliedrecht committed Aug 16, 2024
1 parent ca57688 commit b34dcf7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions agent/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
if (!process.env.P256_SEED || !process.env.AGENT_HOST || !process.env.AGENT_WALLET_KEY) {
if (!process.env.P256_SEED || !process.env.AGENT_HOST || !process.env.AGENT_WALLET_KEY || !process.env.AGENT_DNS) {
throw new Error('P256_SEED, AGENT_HOST or AGENT_WALLET_KEY env variable not set')
}

const AGENT_HOST = process.env.AGENT_HOST
const AGENT_DNS = process.env.AGENT_DNS
const AGENT_WALLET_KEY = process.env.AGENT_WALLET_KEY

const P256_SEED = process.env.P256_SEED
const X509_CERTIFICATE = process.env.X509_CERTIFICATE

export { AGENT_HOST, AGENT_WALLET_KEY, P256_SEED, X509_CERTIFICATE }
export { AGENT_HOST, AGENT_WALLET_KEY, P256_SEED, X509_CERTIFICATE, AGENT_DNS }
6 changes: 3 additions & 3 deletions agent/src/keyMethods/createSelfSignedCertificate.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { type Key, X509Service } from '@credo-ts/core'
import { agent } from '../agent'
import { AGENT_HOST } from '../constants'
import { AGENT_DNS } from '../constants'

export const createSelfSignedCertificate = async (key: Key) =>
(
await X509Service.createSelfSignedCertificate(agent.context, {
key,
extensions: [[{ type: 'url', value: AGENT_HOST }]],
extensions: [[{ type: 'dns', value: AGENT_DNS }]],
notBefore: new Date(0), // Thu Jan 01 1970 01:00:00 GMT+0100 (Central European Standard Time)
notAfter: new Date(10000000000000), // Sat Nov 20 2286 18:46:40 GMT+0100 (Central European Standard Time)
notAfter: new Date(1763799732333), // Sat Nov 22 2025 09:22:12 GMT+0100 (Central European Standard Time)
})
).toString('base64')
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ services:
P256_SEED: ${P256_SEED}
X509_CERTIFICATE: ${X509_CERTIFICATE}
AGENT_HOST: "https://funke.animo.id"
AGENT_DNS: "funke.animo.id"

networks:
- traefik
Expand Down

0 comments on commit b34dcf7

Please sign in to comment.