Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add safety checks to Config.TrustStrategy.trustCustomCertificateSignedBy #1176

Merged
merged 1 commit into from
Mar 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion driver/src/main/java/org/neo4j/driver/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -924,11 +924,16 @@ public TrustStrategy withoutHostnameVerification()
* 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
* each certificate is bounded at the beginning by "-----BEGIN CERTIFICATE-----", and bounded at the end by "-----END CERTIFICATE-----".
*
* @param certFiles the trusted certificate files
* @param certFiles the trusted certificate files, it must not be {@code null} or empty
* @return an authentication config
*/
public static TrustStrategy trustCustomCertificateSignedBy( File... certFiles )
{
Objects.requireNonNull( certFiles, "certFiles can't be null" );
if ( certFiles.length == 0 )
{
throw new IllegalArgumentException( "certFiles can't be empty" );
}
return new TrustStrategy( Strategy.TRUST_CUSTOM_CA_SIGNED_CERTIFICATES, Arrays.asList( certFiles ) );
}

Expand Down