title: Connecting to IBM DB2 using CLI and SSL
body: <p>I was using JDBC to connect to IBM DB2 AS400 for iSeries in my Rails Application.  Now it looks like I will have to move to use the <code>ibm_db</code> gem.</p>
  
  <p><a href="https://github.com/ibmdb/ruby-ibmdb" rel="nofollow noreferrer">https://github.com/ibmdb/ruby-ibmdb</a></p>
  
  <p>I attempted this with <code>irb</code> first and used the following in a command like:</p>
  
  <pre><code>require 'ibm_db'
  conn=IBM_DB.connect("DATABASE=ABCUATDT;hostname=TEST.HERE.COM;PORT=9471;SECURITY=SSL;PROTOCOL=TCPIP;AUTHENTICATION=SERVER;UID=username;PWD=abc1234;", "", "")
  </code></pre>
  
  <p>This gives me the following error:</p>
  
  <blockquote>
    <p>SQL30081N  A communication error has been detected. Communication
    protocol being used: \"SSL\".  Communication API being used:
    \"SOCKETS\".  Location where the error was detected: \"\". 
    Communication function detecting the error: \"sqlccSSLSocketSetup\". 
    Protocol specific error code(s): \"414\"</p>
  </blockquote>
  
  <p>I then try without SSL:</p>
  
  <pre><code>conn=IBM_DB.connect("DATABASE=ABCUATDT;hostname=TEST.HERE.COM;PORT=446;PROTOCOL=TCPIP;AUTHENTICATION=SERVER;UID=username;PWD=abc1234;", "", "")
  </code></pre>
  
  <blockquote>
    <p>SQL30082N  Security processing failed with reason \"15\" (\"PROCESSING
    FAILURE\").  SQLSTATE=08001 SQLCODE=-30082"</p>
  </blockquote>
  
  <p>These ports and username/pw etc all work fine with JDBC, but not using the ibm_db gem.</p>
  
  <p>EDIT:  I tried using different ports, I know that 8471 is open for non-SSL and 9471 is open for SSL.  I decided to skip SSL altogether and I started using the db2cli on my Mac OSX.</p>
  
  <pre><code>db2cli execsql -connstring "database=ABCUATDT;hostname=TEST.HERE.COM;port=8471;uid=username;pwd=abcd1234"
  </code></pre>
  
  <p>This just hangs and doesn't give me a prompt to write SQL:</p>
  
  <blockquote>
    <p>IBM DATABASE 2 Interactive CLI Sample Program (C) COPYRIGHT
    International Business Machines Corp. 1993,1996 All Rights Reserved
    Licensed Materials - Property of IBM US Government Users Restricted
    Rights - Use, duplication or disclosure restricted by GSA ADP Schedule
    Contract with IBM Corp.</p>
  </blockquote>
  
  <p>I then tried the python library AND the DB2 CLI - both of which gave the same errors.  Is there something needed to be changed at the DB2 side?</p>
  
  <p>Why would it work for JDBC but not for the IBM ODBC driver?</p>