Skip to content
Permalink
Browse files
Some resources created with Java 8 cannot be used in Java 16. Provide
scripts to create keystores for Java 8 up to Java 15, and for Java 16
and up. The FTPSClientTest class still fails on Java 16 though, but,
we're getting closer.
  • Loading branch information
garydgregory committed Jul 26, 2021
1 parent af60130 commit bdfbd0cc7294d9d7d494f4148722f5c5dce43eaa
Showing 7 changed files with 18 additions and 5 deletions.
@@ -109,6 +109,12 @@ Supported protocols include: Echo, Finger, FTP, NNTP, NTP, POP3(S), SMTP(S), Tel
<version>2.11.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
@@ -31,6 +31,8 @@

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.output.NullOutputStream;
import org.apache.commons.lang3.JavaVersion;
import org.apache.commons.lang3.SystemUtils;
import org.apache.ftpserver.FtpServer;
import org.apache.ftpserver.FtpServerFactory;
import org.apache.ftpserver.ftplet.FtpException;
@@ -73,7 +75,9 @@ public class FTPSClientTest {

private static final String USER_PROPS_RES = "org/apache/commons/net/ftpsserver/users.properties";

private static final String SERVER_JKS_RES = "org/apache/commons/net/ftpsserver/ftpserver.jks";
private static final String SERVER_JKS_RES_JRE_8 = "org/apache/commons/net/ftpsserver/ftpserver-jre8.jks";

private static final String SERVER_JKS_RES_JRE_16 = "org/apache/commons/net/ftpsserver/ftpserver-jre16.jks";

private static final boolean IMPLICIT = false;

@@ -99,8 +103,6 @@ private static String getTestHomeDirectory() {

@BeforeClass
public static void setUpClass() throws Exception {
TlsProtocols = System.getProperty(JDK_TLS_CLIENT_PROTOCOLS);
//System.setProperty(JDK_TLS_CLIENT_PROTOCOLS, "TLSv1");
setUpClass(IMPLICIT);
}

@@ -133,8 +135,11 @@ private synchronized static void setUpClass(final boolean implicit) throws FtpEx
factory.setPort(SocketPort);

// define SSL configuration
final URL serverJksResource = ClassLoader.getSystemClassLoader().getResource(SERVER_JKS_RES);
Assert.assertNotNull(SERVER_JKS_RES, serverJksResource);
final URL serverJksResource = SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_16)
? ClassLoader.getSystemClassLoader().getResource(SERVER_JKS_RES_JRE_16)
: ClassLoader.getSystemClassLoader().getResource(SERVER_JKS_RES_JRE_8);
System.out.println("Loading " + serverJksResource);
Assert.assertNotNull(SERVER_JKS_RES_JRE_8, serverJksResource);
final SslConfigurationFactory sllConfigFactory = new SslConfigurationFactory();
final File keyStoreFile = FileUtils.toFile(serverJksResource);
Assert.assertTrue(keyStoreFile.toString(), keyStoreFile.exists());
@@ -0,0 +1 @@
keytool -genkeypair -dname "cn=localhost, ou=ApacheCommons, o=ApacheSoftwareFoundation, c=US" -alias ftpserver -keypass password -keystore ftpserver.jks -storepass password -validity 1000 -deststoretype pkcs12 -keyalg "DSA"
@@ -0,0 +1 @@
keytool -genkeypair -dname "cn=localhost, ou=ApacheCommons, o=ApacheSoftwareFoundation, c=US" -alias ftpserver -keypass password -keystore ftpserver.jks -storepass password -validity 1000 -deststoretype pkcs12
Binary file not shown.
Binary file not shown.

0 comments on commit bdfbd0c

Please sign in to comment.