From 02df82ac660c4a5abb7f3198846a284cd630c6a6 Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Fri, 12 Jul 2019 14:00:30 +0200 Subject: [PATCH] fix: acknowledging tls client auth draft fixed --- lib/helpers/configuration.js | 44 +++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/lib/helpers/configuration.js b/lib/helpers/configuration.js index 112d098fa..0d382c957 100644 --- a/lib/helpers/configuration.js +++ b/lib/helpers/configuration.js @@ -444,29 +444,37 @@ module.exports = class Configuration { }); /* eslint-disable no-restricted-syntax */ - for (const endpoint of AUTH_ENDPOINTS) { - if ( - this[`${endpoint}EndpointAuthMethods`].has('tls_client_auth') - && this[`${endpoint}EndpointAuthMethods`].ack !== DRAFTS.get('tlsClientAuth').version - ) { - ENABLED_DRAFTS.add('tlsClientAuth'); - if (typeof this[`${endpoint}EndpointAuthMethods`].ack !== 'undefined') { - throwDraft = true; + { + const draft = DRAFTS.get('tlsClientAuth'); + for (const endpoint of AUTH_ENDPOINTS) { + const { ack } = this[`${endpoint}EndpointAuthMethods`]; + if ( + this[`${endpoint}EndpointAuthMethods`].has('tls_client_auth') + && (Array.isArray(draft.version) ? !draft.version.includes(ack) : ack !== draft.version) + ) { + ENABLED_DRAFTS.add('tlsClientAuth'); + if (typeof ack !== 'undefined') { + throwDraft = true; + } + break; } - break; } } - for (const endpoint of AUTH_ENDPOINTS) { - if ( - this[`${endpoint}EndpointAuthMethods`].has('self_signed_tls_client_auth') - && this[`${endpoint}EndpointAuthMethods`].ack !== DRAFTS.get('selfSignedTlsClientAuth').version - ) { - ENABLED_DRAFTS.add('selfSignedTlsClientAuth'); - if (typeof this[`${endpoint}EndpointAuthMethods`].ack !== 'undefined') { - throwDraft = true; + { + const draft = DRAFTS.get('selfSignedTlsClientAuth'); + for (const endpoint of AUTH_ENDPOINTS) { + const { ack } = this[`${endpoint}EndpointAuthMethods`]; + if ( + this[`${endpoint}EndpointAuthMethods`].has('self_signed_tls_client_auth') + && (Array.isArray(draft.version) ? !draft.version.includes(ack) : ack !== draft.version) + ) { + ENABLED_DRAFTS.add('selfSignedTlsClientAuth'); + if (typeof ack !== 'undefined') { + throwDraft = true; + } + break; } - break; } } /* eslint-enable */