Topic: How to set subject alternative name (SAN) in WolfSSL?
Hi there,
I have difficulty with setting the subject alternative name (IP address: xxx.xxx.xxx.xxx) for the certificate in WolfSSL. I tried using the method in this post https://www.wolfssl.com/forums/topic140 … l-api.html as the code below:
Cert myCert;
char myAltNames[CTC_MAX_ALT_SIZE]="IP Address: 169.254.50.10";
XMEMCPY(myCert.altNames, myAltNames, XSTRLEN(myAltNames));
myCert.altNamesSz = XSTRLEN(myAltNames);
And i also tried using the function wc_SetAltNames() with a .pem file (full details in this page https://wolfssl.com/doxygen/group__ASN.html). None of them work for me, they both generate invalid certificates. In Firefox, it has such error code: SSL_ERROR_RX_RECORD_TOO_LONG.
When i open the generated certificate file in windows, it says invalid. The source code of the certificate look quiet invalid to me too:
-----BEGIN CERTIFICATE-----
MIIDyDAAoAMCAQICCAFW11SX7K/5MAoGCCqGSM49BAMCMIGEMQswCQYDVQQGEwJO
WjETMBEGA1UECAwKV2VsbGluZ3RvbjESMBAGA1UEBwwJTmdhdXJhbmdhMRAwDgYD
VQQKDAc0UkYgTHRkMRkwFwYDVQQLDBBSYWRpbyBXRUIgU2VydmVyMR8wHQYDVQQD
DBZBcHJpc2EgU1IrIFIxMzEwMDAzODY2MCIYDzIwMTkxMDAzMDAwMDAwWhgPMjAz
OTA5MjkwMDAwMDBaMIGEMQswCQYDVQQGEwJOWjETMBEGA1UECAwKV2VsbGluZ3Rv
bjESMBAGA1UEBwwJTmdhdXJhbmdhMRAwDgYDVQQKDAc0UkYgTHRkMRkwFwYDVQQL
DBBSYWRpbyBXRUIgU2VydmVyMR8wHQYDVQQDDBZBcHJpc2EgU1IrIFIxMzEwMDAz
ODY2MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEEV+ZJjpKHip6F46e2/8RTyws
MCWMAfvHGR5DxNrnvGcIM8DSn1XRnCC4j8ObpUBNpWo/B0cwsdEFxfA3zT8Oi6Me
MBwwGgYDVR0RBBMwEYIJQXByaXNhU1IrhwSsER4KAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAADAKBggqhkjOPQQDAgNIADBFAiEA1cVJAWWY
pL+C5ZwWuV2cDv7G7FFTQR7E40KeMtu3i9YCIEH9kvgojBSxuwUy074Jo5G8x0iy
pFXFg5W/VdSGcGc7
-----END CERTIFICATE-----
Without anything related to this alternative name, my code works perfectly fine and the generated certificate was "valid" (with no SAN field).
How could I solve this? All I want is add just some like this in the subject alternative name field in the certificate file:
IP Address: XXX.XXX.XXX.XXX
Thank you in advance.