-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pki): add support of flatten rdn structure
- Loading branch information
Showing
2 changed files
with
29 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { RelativeDistinguishedNames } from "@yonagi/common/types/pki/RelativeDistinguishedNames" | ||
import * as asn1js from "asn1js" | ||
import * as pkijs from "pkijs" | ||
|
||
import { OID_CommonName, OID_OrganizationName } from "../consts" | ||
|
||
export class ExtendedRelativeDistinguishedNames extends pkijs.RelativeDistinguishedNames { | ||
toSchema(): asn1js.Sequence { | ||
return new asn1js.Sequence({ | ||
value: Array.from(this.typesAndValues, (element) => new asn1js.Set({ value: [element.toSchema()] })), | ||
}) | ||
} | ||
} | ||
|
||
export function convertRdnToPkijsRdn(rdn: RelativeDistinguishedNames): ExtendedRelativeDistinguishedNames { | ||
return new ExtendedRelativeDistinguishedNames({ | ||
typesAndValues: [ | ||
new pkijs.AttributeTypeAndValue({ | ||
type: OID_CommonName, | ||
value: new asn1js.BmpString({ value: rdn.commonName }), | ||
}), | ||
new pkijs.AttributeTypeAndValue({ | ||
type: OID_OrganizationName, | ||
value: new asn1js.BmpString({ value: rdn.organizationName }), | ||
}), | ||
], | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters