Skip to content

Commit

Permalink
Make generateUserCertificate backwards compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Leblow committed Apr 9, 2024
1 parent 27a1c84 commit 1ecce76
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions packages/identity/src/createUserCert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,24 @@ async function generateUserCertificate({
let altNames

try {
nickname = attr?.[1].values[0].valueBlock.value
peerId = attr?.[2].values[0].valueBlock.value
onionAddress = attr?.[3].values[0].valueBlock.value
// MIGRATION: We removed dmPublicKey from the attributes at
// position 1. However, we maintain backwards compatibility for
// existing CSRs, if we ever need to re-issue certificates.
//
// TODO: Perhaps we should retreive values by their field type
// instead of their position.
if (attr?.length === 5) {
// publicKey = attr[0]
// dmPublicKey = attr[1]
nickname = attr?.[2].values[0].valueBlock.value
peerId = attr?.[3].values[0].valueBlock.value
onionAddress = attr?.[4].values[0].valueBlock.value
} else {
// publicKey = attr[0]
nickname = attr?.[1].values[0].valueBlock.value
peerId = attr?.[2].values[0].valueBlock.value
onionAddress = attr?.[3].values[0].valueBlock.value
}
altNames = new GeneralNames({
names: [
new GeneralName({
Expand Down

0 comments on commit 1ecce76

Please sign in to comment.