1'use strict'; 2 3const { 4 certExportChallenge, 5 certExportPublicKey, 6 certVerifySpkac 7} = internalBinding('crypto'); 8const { 9 validateBuffer 10} = require('internal/validators'); 11 12const { 13 getArrayBufferView 14} = require('internal/crypto/util'); 15 16function verifySpkac(spkac) { 17 validateBuffer(spkac, 'spkac'); 18 return certVerifySpkac(spkac); 19} 20 21function exportPublicKey(spkac, encoding) { 22 return certExportPublicKey( 23 getArrayBufferView(spkac, 'spkac', encoding) 24 ); 25} 26 27function exportChallenge(spkac, encoding) { 28 return certExportChallenge( 29 getArrayBufferView(spkac, 'spkac', encoding) 30 ); 31} 32 33// For backwards compatibility reasons, this cannot be converted into a 34// ES6 Class. 35function Certificate() { 36 if (!(this instanceof Certificate)) 37 return new Certificate(); 38} 39 40Certificate.prototype.verifySpkac = verifySpkac; 41Certificate.prototype.exportPublicKey = exportPublicKey; 42Certificate.prototype.exportChallenge = exportChallenge; 43 44Certificate.exportChallenge = exportChallenge; 45Certificate.exportPublicKey = exportPublicKey; 46Certificate.verifySpkac = verifySpkac; 47 48module.exports = Certificate; 49