The main purpose of the java program below is to use the AS400FileRecordDescription class from the jtopen (version 9.6) to retrieve the record format of a physical file on iseries. It does that by calling the retrieveRecordFormat() method in this class.
This program works fine if the connection is an unsecured connection (the connection url does not contain the secure=true paramater). But under a secured connection (the connection url contains the secure=true paramater), it failed with this error: "javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake". Any idea what I'm doing wrong here?
import java.sql.Connection;
import java.sql.DriverManager;
import com.ibm.as400.access.AS400;
import com.ibm.as400.access.AS400FileRecordDescription;
import com.ibm.as400.access.AS400JDBCConnection;
import com.ibm.as400.access.RecordFormat;
public class TestIseriesSecureConnection {
public static void main(String[] args) {
Connection conn = null;
AS400 system = null;
try {
// get standard jdbc connection
Class.forName("com.ibm.as400.access.AS400JDBCDriver");
// notice the secure=true parameter, if that is removed, the program works fine.
conn = DriverManager.getConnection("jdbc:as400://myiseries;secure=true;naming=system;errors=full;prompt=false;libraries=*LIBL;timeFormat=iso;dateFormat=iso;dateSeparator=-", "myuser", "mypassword");
// cast connection into AS400 jdbc connection class to get the AS400 object
AS400JDBCConnection as400Conn = (AS400JDBCConnection) conn;
system = as400Conn.getSystem();
// get the record format of a file on iseries
RecordFormat recordFormats[] = null;
AS400FileRecordDescription fileRecordDescription = new AS400FileRecordDescription(system, "/QSYS.LIB/%LIBL%.LIB/MYFILE.FILE");
// This is where it error out if the connection is a secure connection
recordFormats = fileRecordDescription.retrieveRecordFormat();
for (int myIx = 0; myIx < recordFormats.length; myIx++) {
System.out.println(recordFormats[myIx].toString());
}
conn.close();
}
catch(Exception ex) {
ex.printStackTrace();
}
finally {
try {
if (conn != null) {
conn.close();
}
}
catch (Exception ex) {
ex.printStackTrace();
}
}
System.exit(0);
}
}
After a bit more back and forth with IBM support, we finally figured out that the problem was caused by the retrieveRecordFormat method is using the DDM/DRDA service to serve the request. We've ssl cert install on several diff host servers but not on the DDM/DRDA. That explained why other type of requests are working fine under ssl. So, once I've the cert installed on the DDM/DRDA host server, the program works fine even with the plain old AS400 object.