title: Access to MySql with SSL from C/C++
body: <p>I've configured MySql to use SSL and it worked well in PHP. But when i'm trying to connect to the databases with a C/C++ program, it doesn't work.</p>
  
  <h2>Variables :</h2>
  
  <pre><code>host = "localhost"
  psw = "pass"
  db = "database"
  </code></pre>
  
  <h2>Without SSL :</h2>
  
  <pre><code>usr = "userNOSSL"
  conn = mysql_init(NULL);
  mysql_real_connect(conn, host, usr, psw, db, 0, NULL, 0);
  </code></pre>
  
  <p>This one worked well. i can easily retrieve data with :</p>
  
  <pre><code>query = "SELECT x FROM y"
  
  mysql_query(conn, query);
  
  result = mysql_store_result(conn);
  
  num_fields = mysql_num_fields(result);
  
  while ((row = mysql_fetch_row(result)))
  {
      for(i = 0; i &lt; num_fields; i++)
      {
          printf("%s ", row[i] ? row[i] : "NULL");
      }
      printf("\n");
  }
  
  mysql_free_result(result);
  </code></pre>
  
  <h2>With SSL (CLIENT_SSL tag) :</h2>
  
  <pre><code>usr = "userSSL"
  conn = mysql_init(NULL);
  mysql_real_connect(conn, host, usr, psw, db, 0, NULL, CLIENT_SSL);
  </code></pre>
  
  <p><strong>The Error</strong></p>
  
  <blockquote>
    <p>Error : my "MYSQL *conn;" object is not getting parameters like "without ssl". 
            so, it occurs an exception : </p>
  </blockquote>
  
  <pre><code>A first chance of exception at 0x0f18c274 in test_Class.exe : 0xC0000005: 
  Acces violation when reading on location 0x00000048.
  An unhandled exception at 0x0f18c274 in test_Class.exe : 0xC0000005: 
  Acces violation when reading on location 0x00000048.
  </code></pre>
  
  <p>at this line :</p>
  
  <pre><code>num_fields = mysql_num_fields(result);
  </code></pre>
  
  <p>Same error if i do :</p>
  
  <pre><code>mysql_ssl_set(.SOMEOPTIONTHERE.)
  mysql_real_connect(conn, host, usr, psw, db, 0, NULL, 0);
  </code></pre>
  
  <p>Thanks in advance.</p>