feat: only allow DH key exchange in the first 60 seconds

This commit is contained in:
Vlad Stan 2022-08-16 14:08:04 +03:00
parent 7c796f428a
commit f73f5a90c9

View file

@ -577,12 +577,28 @@ async function serialSigner(path) {
}, },
handleDhExchangeResponse: async function (res = '') { handleDhExchangeResponse: async function (res = '') {
console.log('### handleDhExchangeResponse', res) console.log('### handleDhExchangeResponse', res)
const [pubKeyHex] = res.trim().split(' ') const [statusCode, data] = res.trim().split(' ')
if (!pubKeyHex) { let pubKeyHex, errorMessage, captionMessage
switch (statusCode) {
case '0':
pubKeyHex = data
if(!data) errorMessage = 'Failed to exchange DH secret!'
break
case '1':
errorMessage = 'Secure connection can only be established in the first 60 seconds after start-up!'
captionMessage = 'Restart and try again'
break
default:
errorMessage = 'Unexpected error code'
break
}
if (errorMessage) {
this.$q.notify({ this.$q.notify({
type: 'warning', type: 'warning',
message: 'Failed to exchange DH secret!', message: errorMessage,
caption: `${res}`, caption: captionMessage || '',
timeout: 10000 timeout: 10000
}) })