Last active
February 5, 2020 04:11
-
-
Save tresf/c8fe9f70bdb32b62d333bdc75ae34936 to your computer and use it in GitHub Desktop.
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
qz.security.setSignaturePromise(async (toSign) => { | |
var pk = KEYUTIL.getKey(privateKey); | |
var sig = new KJUR.crypto.Signature({"alg": "SHA1withRSA"}); // Use "SHA1withRSA" for QZ Tray 2.0 and older | |
sig.init(pk); | |
sig.updateString(toSign); | |
var hex = sig.sign(); | |
console.log("DEBUG: \n\n" + stob64(hextorstr(hex))); | |
return stob64(hextorstr(hex)); | |
}); | |
qz.security.setCertificatePromise(async () => { | |
return "-----BEGIN CERTIFICATE-----\n" + | |
// ... | |
}); |
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
/** Called to create new promise (using {@link _qz.security.certPromise}) for certificate retrieval. */ | |
callCert: function() { | |
if (typeof _qz.security.certPromise.then === 'function' || _qz.security.certPromise.constructor.name === "AsyncFunction") { | |
return _qz.security.certPromise(); | |
} else { | |
return _qz.tools.promise(_qz.security.certPromise); | |
} | |
}, |
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
/** Called to create new promise (using {@link _qz.security.signaturePromise}) for signed calls. */ | |
callSign: function(toSign) { | |
if (typeof _qz.security.signaturePromise.then === 'function' || _qz.security.signaturePromise.constructor.name === "AsyncFunction") { | |
// Must be a promise, resolve toSign directly | |
return _qz.security.signaturePromise(toSign); | |
} else { | |
// Standard function, wrap as a promise | |
return _qz.tools.promise(_qz.security.signaturePromise(toSign)); | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment