File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -250,14 +250,18 @@ function spkiFromX509(buf: Uint8Array) {
250
250
return encodeBase64 ( tbsCertificate [ tbsCertificate [ 0 ] . raw [ 0 ] === 0xa0 ? 6 : 5 ] . raw )
251
251
}
252
252
253
- let X509Certificate : any
253
+ let createPublicKey : any
254
254
function getSPKI ( x509 : string ) : string {
255
- if (
255
+ try {
256
256
// @ts -ignore
257
- ( X509Certificate ||= globalThis . process ?. getBuiltinModule ?.( 'node:crypto' ) ?. X509Certificate )
258
- ) {
257
+ createPublicKey ??= globalThis . process ?. getBuiltinModule ?.( 'node:crypto' ) ?. createPublicKey
258
+ } catch {
259
+ createPublicKey = 0
260
+ }
261
+
262
+ if ( createPublicKey ) {
259
263
try {
260
- return new X509Certificate ( x509 ) . publicKey . export ( { format : 'pem' , type : 'spki' } )
264
+ return new createPublicKey ( x509 ) . export ( { format : 'pem' , type : 'spki' } )
261
265
} catch { }
262
266
}
263
267
const pem = x509 . replace ( / (?: - - - - - (?: B E G I N | E N D ) C E R T I F I C A T E - - - - - | \s ) / g, '' )
You can’t perform that action at this time.
0 commit comments