@@ -175,9 +175,21 @@ const der = Buffer.from(
175175
176176 assert . strictEqual ( x509 . checkIP ( '127.0.0.1' ) , undefined ) ;
177177 assert . strictEqual ( x509 . checkIP ( '::' ) , undefined ) ;
178- assert . strictEqual ( x509 . checkHost ( 'agent1' ) , 'agent1' ) ;
178+ // OpenSSL 4.1 no longer checks the subject DN by default.
179+ // https://github.com/openssl/openssl/pull/31982
180+ for ( const options of [ undefined , { subject : 'default' } ] ) {
181+ assert . strictEqual ( x509 . checkHost ( 'agent1' , options ) ,
182+ hasOpenSSL ( 4 , 1 ) ? undefined : 'agent1' ) ;
183+ assert . strictEqual ( x509 . checkEmail ( 'ry@tinyclouds.org' , options ) ,
184+ hasOpenSSL ( 4 , 1 ) ? undefined : 'ry@tinyclouds.org' ) ;
185+ }
186+ assert . strictEqual ( x509 . checkHost ( 'agent1' , { subject : 'always' } ) , 'agent1' ) ;
187+ assert . strictEqual ( x509 . checkHost ( 'agent1' , { subject : 'never' } ) , undefined ) ;
179188 assert . strictEqual ( x509 . checkHost ( 'agent2' ) , undefined ) ;
180- assert . strictEqual ( x509 . checkEmail ( 'ry@tinyclouds.org' ) , 'ry@tinyclouds.org' ) ;
189+ assert . strictEqual ( x509 . checkEmail ( 'ry@tinyclouds.org' , { subject : 'always' } ) ,
190+ 'ry@tinyclouds.org' ) ;
191+ assert . strictEqual ( x509 . checkEmail ( 'ry@tinyclouds.org' , { subject : 'never' } ) ,
192+ undefined ) ;
181193 assert . strictEqual ( x509 . checkEmail ( 'sally@example.com' ) , undefined ) ;
182194 assert . throws ( ( ) => x509 . checkHost ( 'agent\x001' ) , {
183195 code : 'ERR_INVALID_ARG_VALUE'
0 commit comments