Hi Eric,
You should be able to extract the public key from a DER-encoded X.509 certificate into an RsaKey structure using something similar to this:
int ret;
int derCertSz;
byte derCert[4096];
FILE* file;
RsaKey pubKey;
word32 idx = 0;
DecodedCert cert;
/* open and read DER-formatted cert into buffer */
file = fopen("./client-cert.der", "rb");
if (!file)
// error reading file
derCertSz = fread(derCert, 1, sizeof(derCert), file);
fclose(file);
/* initialize DecodedCert with DER cert */
InitDecodedCert(&cert, derCert, derCertSz, 0);
ret = ParseCert(&cert, CERT_TYPE, NO_VERIFY, 0);
if (ret != 0)
// ParseCert failed
/* extract the public key from the cert */
InitRsaKey(&pubKey, 0);
idx = 0;
ret = RsaPublicKeyDecode(cert.publicKey, &idx, &pubKey, cert.pubKeySize);
if (ret != 0)
// RsaPublicKeyDecode failedIn order to use the InitDecodedCert() and ParseCert() functions, you'll need to add the WOLFSSL_TEST_CERT define to the wolfSSL preprocessor flags (C_EXTRA_FLAGS) when compiling the library, and then to your application ones as well.
After doing the above, you'll have an RsaKey structure containing the public key which you can then use with the RSA functions.
Hope this helps.
Best Regards,
Chris