title: How to parse openssl config file from C++ code?
body: <p>I have a question regarding openssl. I am looking for some examples where we can access/retrieve the <code>name=value</code> pair from the <code>openssl.cnf</code> file. For example I have below <code>openssl.cnf</code> file:</p>
  <pre><code>.
  .
  [engine_section] 
  pkcs11 = pkcs11_section
  
  [pkcs11_section]
  engine_id = pkcs11 
  dynamic_path = /usr/lib/engines-1.1/pkcs11.so
  MODULE_PATH = /usr/lib/libtpm2_pkcs11.so
  PIN = 12xx
  default_algorithms = ALL
  init = 0
  </code></pre>
  <p>Now, if I want to access PIN value within the C++ source code, how can this be achieved? Does openssl has any parsing tool for such cases? Any alternative way to do this is also helpful.</p>
  <p>The official doc of <a href="https://www.openssl.org/docs/man1.1.1/man5/config.html" rel="nofollow noreferrer">openssl config</a> file mentions</p>
  <blockquote>
  <p>The OpenSSL CONF library can be used to read configuration files.</p>
  </blockquote>
  <p>But I could not find any examples of using this library.</p>
  <p>Thanks in advance.</p>
  <p>P.S: Please let me know if further info is needed</p>