title: How to implement SNI using openssl configuration file?
body: <p>I have implemented SNI using OpenSSL but not using an OpenSSL config file (cnf). I am loading a server SSL_CTX doing the following:</p>
  
  <pre><code> FILE *fp;
   CONF *cnf = NULL;
   long eline;
  
   fp = fopen("/somepath/app.cnf", "r");
   if (fp == NULL) {
       fprintf(stderr, "Error opening configuration file\n");
       /* Other missing configuration file behaviour */
   } else {
       cnf = NCONF_new(NULL);
       if (NCONF_load_fp(cnf, fp, &amp;eline) == 0) {
           fprintf(stderr, "Error on line %ld of configuration file\n", eline);
           ERR_print_errors_fp(stderr);
           /* Other malformed configuration file behaviour */
       } else if (CONF_modules_load(cnf, "appname", 0) &lt;= 0) {
           fprintf(stderr, "Error configuring application\n");
           ERR_print_errors_fp(stderr);
           /* Other configuration error behaviour */
       }
       fclose(fp);
       NCONF_free(cnf);
   }
  </code></pre>
  
  <p>It works fine, but now I am trying to implement server-side SNI using the OpenSSL config file and I don't know how can I get the required information to do it. I have taken a look to <a href="https://stackoverflow.com/questions/5113333/how-to-implement-server-name-indication-sni">How to implement Server Name Indication (SNI)</a> and this is a good explanation to do it without openssl config file. But that doesn't work using the file.</p>
  
  <p>How can I determine if the server have the certificate requested? Maybe openssl provides the proper certificate by itself?</p>