<p>I have a C/C++ application and I need to create a X509 pem certificate containing both a public and private key.  The certificate can be self signed, or unsigned, doesn't matter.</p>

<p>I want to do this inside an app, not from command line.</p>

<p>What OpenSSL functions will do this for me?  Any sample code is a bonus!</p>

Any chance of doing this via a
```
system
```
call from within your app?  Several good reasons for doing this:
Licensing:  Calling the
```
openssl
```
executable arguably separates it from your application and may provide certain advantages.
Disclaimer: consult a lawyer on this.
Documentation:  OpenSSL comes with
phenomenal
command-line documentation that greatly simplifies a potentially complicated tool.
Testability:  you can exercise OpenSSL from the command line until you understand exactly how to create your certs.  There are a
lot
of options; expect to spend about a day on this until you get all the details right.  After that, it's trivial to incorporate the command into your app.
If you choose to use the API, check the
```
openssl-dev
```
developers' list on www.openssl.org.
Good luck!