Skip to content

Commit c79bf7a

Browse files
committed
DEVEXP-515 : Provide better error message for "OPENSSL_internal:WRONG_VERSION_NUMBER"
1 parent ad8ce89 commit c79bf7a

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

etc/test-config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,5 +134,14 @@ module.exports = {
134134
authType: restAuthType,
135135
basePath: '',
136136
enableGzippedResponses: true
137+
},
138+
restWriterConnectionWithSsl: {
139+
host: testHost,
140+
port: restPort,
141+
user: restWriterUser,
142+
password: restWriterPassword,
143+
authType: restAuthType,
144+
enableGzippedResponses: true,
145+
ssl: true
137146
}
138147
};

lib/responder.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1236,7 +1236,12 @@ function operationErrorListener(error) {
12361236
return;
12371237
}
12381238
}
1239-
1239+
const errorMessage = error.message.toString();
1240+
if(errorMessage.includes('EPROTO') && errorMessage.includes('SSL routines') &&
1241+
(errorMessage.includes('wrong version number') || errorMessage.includes('WRONG_VERSION_NUMBER'))) {
1242+
error = new Error('You have attempted to access an HTTP server using HTTPS. Please check your configuration.\n' +
1243+
errorMessage);
1244+
}
12401245
operation.dispatchError(error);
12411246

12421247
operation.done = true;

test-basic/client.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,22 @@ describe('database clients', function() {
147147
done(error);
148148
}
149149
});
150+
151+
it('should throw Error when SSL is used and server does not use SSL', function(done) {
152+
const db = marklogic.createDatabaseClient(testconfig.restWriterConnectionWithSsl);
153+
db.documents.write({
154+
uri: '/test/write/string1.json',
155+
contentType: 'application/json',
156+
content: '{"key1":"value 1"}'
157+
})
158+
.result()
159+
.catch(error => {
160+
try{
161+
assert(error.message.toString().includes('You have attempted to access an HTTP server using HTTPS. Please check your configuration.'));
162+
done();
163+
} catch(err){
164+
done(err);
165+
}
166+
});
167+
});
150168
});

0 commit comments

Comments
 (0)