title: Setting Up SSL - Initial steps
body: <p>I'm trying to convert my sockets program over to SSL. I'm just laying out the initial setup, and have come upon some run-time errors that I don't know how to resolve. Note: there is a file called 'my_server.pem' in the same directory as the c file. </p>
  
  <p>Can anyone help me? Thanks!</p>
  
  <pre><code>#include &lt;openssl/bio.h&gt; // BIO objects for I/O
  #include &lt;openssl/ssl.h&gt; // SSL and SSL_CTX for SSL connections
  #include &lt;openssl/err.h&gt; // Error reporting
  
  int main(int argc, char *argv[]) {
  
      // data structures for SSL
      BIO *bio;
      SSL *ssl;
      SSL_CTX *ctx;
  
      // initialize openSSL
      SSL_load_error_strings();
      ERR_load_BIO_strings();
      OpenSSL_add_all_algorithms();
  
      // set up the SSL context
      ctx = SSL_CTX_new(SSLv23_client_method());
  
      if (ctx == NULL)
          fprintf(stderr, "context is null\n");
  
      // load the trust store
      if (! SSL_CTX_load_verify_locations(ctx, "my_server.pem", NULL)) {
          fprintf(stderr, "Error loading trust store\n");
          ERR_print_errors_fp(stderr);
          SSL_CTX_free(ctx);
          return 0;
      }
      fprintf(stderr, "made it\n");
  
      //...
  
      return 0;
  }
  </code></pre>
  
  <p>These are the error messages:</p>
  
  <pre><code>140735285130080:error:02001002:system library:fopen:No such file or directory:bss_file.c:169:fopen('my_server.pem','r')
  140735285130080:error:2006D080:BIO routines:BIO_new_file:no such file:bss_file.c:172:
  140735285130080:error:0B084002:x509 certificate routines:X509_load_cert_crl_file:system lib:by_file.c:274:
  </code></pre>