Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pki): add support of flatten rdn structure #20

Merged
merged 3 commits into from
Jun 13, 2024
Merged

Conversation

amphineko
Copy link
Owner

Creating a more compatible RelativeDistinguishedNames, which replacing one set of multiple DN elements with individual sets for each element by overriding serialization.

Fix #19.

The solution is originally posted by @YuryStrozhevsky in PeculiarVentures/PKI.js#169 (comment)

@DariusSG
Copy link
Contributor

DariusSG commented Jun 2, 2024

Fix for proper encoding of issuer

  1. Change usage of BmpString to PrintableString

  2. Re-encode the issuer subject instead of using it directly

*** utils_new.ts        Sun Jun  2 21:13:35 2024
--- utils.ts    Sun Jun  2 21:14:06 2024
***************
*** 117,124 ****
          if (!(issuer instanceof PkijsCertificate)) {
              throw new Error("Cannot derive issuer's subject from non-Pkijs certificate factory")
          }
!         const issuer_subject = convertPkijsRdnToRdn(issuer.pkijsCertificate.subject)
!         cert.issuer = convertRdnToPkijsRdn(issuer_subject)
      } else {
          cert.issuer = cert.subject
      }
--- 117,123 ----
          if (!(issuer instanceof PkijsCertificate)) {
              throw new Error("Cannot derive issuer's subject from non-Pkijs certificate factory")
          }
!         cert.issuer = issuer.pkijsCertificate.subject
      } else {
          cert.issuer = cert.subject
      }
***************
*** 141,144 ****
  export function getSerialNumberFromCertificate(cert: pkijs.Certificate): string {
      return Buffer.from(cert.serialNumber.valueBlock.valueHexView).toString("hex").toLowerCase()
  }
- 
--- 140,142 ----

@amphineko
Copy link
Owner Author

amphineko commented Jun 2, 2024

@DariusSG Thanks for your input.

Based on your suggestions I also migrated the RDN structure of issuers, and used PrintableString instead. Can you confirm if it works?

Tip: You can use the Docker image generated for this PR.

@DariusSG
Copy link
Contributor

DariusSG commented Jun 4, 2024

Based on your suggestions I also migrated the RDN structure of issuers, and used PrintableString instead. Can you confirm if it works?

Yep, It works. You can merge it.

@amphineko amphineko merged commit 3fd3c2e into master Jun 13, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Android crash when connecting.
2 participants