File tree Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Original file line number Diff line number Diff 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} ;
Original file line number Diff line number Diff 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 ;
Original file line number Diff line number Diff 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} ) ;
You can’t perform that action at this time.
0 commit comments