-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from wwWallet/verification-flow-fixes
Combined presentation and other fixes
- Loading branch information
Showing
14 changed files
with
367 additions
and
226 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
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
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
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
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,18 @@ | ||
import { X509Certificate } from "crypto"; | ||
|
||
export async function verifyCertificateChain(rootCert: string, pemCertChain: string[]) { | ||
const x509TrustAnchor = new X509Certificate(rootCert); | ||
const isLastCertTrusted = new X509Certificate(pemCertChain[pemCertChain.length - 1]).verify(x509TrustAnchor.publicKey); | ||
if (!isLastCertTrusted) { | ||
return false; | ||
} | ||
for (let i = 0; i < pemCertChain.length; i++) { | ||
if (pemCertChain[i + 1]) { | ||
const isTrustedCert = new X509Certificate(pemCertChain[i]).verify(new X509Certificate(pemCertChain[i + 1]).publicKey); | ||
if (!isTrustedCert) { | ||
return false; | ||
} | ||
} | ||
} | ||
return true; | ||
} |
Oops, something went wrong.