File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -261,7 +261,17 @@ function passwordDigest(username: string, password: string) {
261
261
throw new MongoInvalidArgumentError ( 'Password cannot be empty' ) ;
262
262
}
263
263
264
- const md5 = crypto . createHash ( 'md5' ) ;
264
+ let md5 : crypto . Hash ;
265
+ try {
266
+ md5 = crypto . createHash ( 'md5' ) ;
267
+ } catch ( err ) {
268
+ if ( crypto . getFips ( ) ) {
269
+ // This error is (slightly) more helpful than what comes from OpenSSL directly, e.g.
270
+ // 'Error: error:060800C8:digital envelope routines:EVP_DigestInit_ex:disabled for FIPS'
271
+ throw new Error ( 'Auth mechanism SCRAM-SHA-1 is not supported in FIPS mode' ) ;
272
+ }
273
+ throw err ;
274
+ }
265
275
md5 . update ( `${ username } :mongo:${ password } ` , 'utf8' ) ;
266
276
return md5 . digest ( 'hex' ) ;
267
277
}
You can’t perform that action at this time.
0 commit comments