don't try to verify messages if you can't decode base64
parent
ecd3f68265
commit
7ab65367c5
10
rpc.js
10
rpc.js
|
@ -18,8 +18,12 @@ var isValidChannel = function (chan) {
|
|||
var checkSignature = function (signedMsg, publicKey) {
|
||||
if (!(signedMsg && publicKey)) { return null; }
|
||||
|
||||
var signedBuffer = Nacl.util.decodeBase64(signedMsg);
|
||||
var pubBuffer = Nacl.util.decodeBase64(publicKey);
|
||||
try {
|
||||
var signedBuffer = Nacl.util.decodeBase64(signedMsg);
|
||||
var pubBuffer = Nacl.util.decodeBase64(publicKey);
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var opened = Nacl.sign.open(signedBuffer, pubBuffer);
|
||||
|
||||
|
@ -46,7 +50,7 @@ RPC.create = function (config, cb) {
|
|||
|
||||
var msg = checkSignature(signed, publicKey);
|
||||
if (!msg) {
|
||||
return void respond("INVALID_SIGNATURE");
|
||||
return void respond("INVALID_SIGNATURE_OR_PUBLIC_KEY");
|
||||
}
|
||||
|
||||
if (typeof(msg) !== 'object') {
|
||||
|
|
Loading…
Reference in New Issue