Skip to content

Commit d133329

Browse files
authored
Add safety checks to Config.TrustStrategy.trustCustomCertificateSignedBy (#1172)
1 parent 3aea8a0 commit d133329

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

driver/src/main/java/org/neo4j/driver/Config.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,11 +838,16 @@ public TrustStrategy withoutHostnameVerification()
838838
* The certificate(s) in the file(s) must be encoded using PEM encoding, meaning the certificates in the file(s) should be encoded using Base64, and
839839
* each certificate is bounded at the beginning by "-----BEGIN CERTIFICATE-----", and bounded at the end by "-----END CERTIFICATE-----".
840840
*
841-
* @param certFiles the trusted certificate files
841+
* @param certFiles the trusted certificate files, it must not be {@code null} or empty
842842
* @return an authentication config
843843
*/
844844
public static TrustStrategy trustCustomCertificateSignedBy( File... certFiles )
845845
{
846+
Objects.requireNonNull( certFiles, "certFiles can't be null" );
847+
if ( certFiles.length == 0 )
848+
{
849+
throw new IllegalArgumentException( "certFiles can't be empty" );
850+
}
846851
return new TrustStrategy( Strategy.TRUST_CUSTOM_CA_SIGNED_CERTIFICATES, Arrays.asList( certFiles ) );
847852
}
848853

0 commit comments

Comments
 (0)