Skip to content

Commit 8049ec6

Browse files
authored
Add safety checks to Config.TrustStrategy.trustCustomCertificateSignedBy (#1172) (#1176)
1 parent 05eb4a3 commit 8049ec6

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
@@ -924,11 +924,16 @@ public TrustStrategy withoutHostnameVerification()
924924
* 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
925925
* each certificate is bounded at the beginning by "-----BEGIN CERTIFICATE-----", and bounded at the end by "-----END CERTIFICATE-----".
926926
*
927-
* @param certFiles the trusted certificate files
927+
* @param certFiles the trusted certificate files, it must not be {@code null} or empty
928928
* @return an authentication config
929929
*/
930930
public static TrustStrategy trustCustomCertificateSignedBy( File... certFiles )
931931
{
932+
Objects.requireNonNull( certFiles, "certFiles can't be null" );
933+
if ( certFiles.length == 0 )
934+
{
935+
throw new IllegalArgumentException( "certFiles can't be empty" );
936+
}
932937
return new TrustStrategy( Strategy.TRUST_CUSTOM_CA_SIGNED_CERTIFICATES, Arrays.asList( certFiles ) );
933938
}
934939

0 commit comments

Comments
 (0)