OK so it seems that to use DeviceAuth_GetCertificatePath
that you must add tlsutils to the list of libraries in cMakeLists.txt
So I guess failing to mention that is a deficiency of the azsphere documentation,
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Az Sphere 20.10
Linking is giving undefined reference to `DeviceAuth_GetCertificatePath'
C:/Program Files (x86)/Microsoft Azure Sphere SDK/Sysroots/7/tools/gcc/real-ld.exe: CMakeFiles/PrivateNetworkServices.dir/main.c.obj: in function main': C:\Users\trt-dev6\azSphere\azure-sphere-samples-master\azure-sphere-samples-master\Samples\PrivateNetworkServices\out\ARM-Debug/../../main.c:448: undefined reference to
DeviceAuth_GetCertificatePath'
Can anyone help resolve that please?
OK so it seems that to use DeviceAuth_GetCertificatePath
that you must add tlsutils to the list of libraries in cMakeLists.txt
So I guess failing to mention that is a deficiency of the azsphere documentation,
#define SSL_FILETYPE_PEM 1
if (Application_IsDeviceAuthReady(&authReady) == 0) {
if (authReady) {
const char *certPath = DeviceAuth_GetCertificatePath();
WOLFSSL_X509 *x509;
x509 = wolfSSL_X509_load_certificate_file(certPath, SSL_FILETYPE_PEM);
/* ------ EXTRACT CERTIFICATE ELEMENTS ------ */
/* extract subjectName */
name = wolfSSL_X509_get_subject_name(x509);
if (name == NULL)
Log_Debug("wolfSSL_X509_get_subject_name failed");
else
Log_Debug("subject name:%s\n\r", wolfSSL_X509_NAME_oneline(name, subjectName, 80));
/* extract issuerName */
name = wolfSSL_X509_get_issuer_name(x509);
if (name == NULL)
Log_Debug("wolfSSL_X509_get_issuer_name failed");
else
Log_Debug("issuer name:%s\n\r", wolfSSL_X509_NAME_oneline(name, issuerName, 80));
// see https://www.wolfssl.com/forums/topic958-using-notbefore-notafter.html
char *b = wolfSSL_X509_notBefore(x509);
Log_Debug("not before:%s\n\r", &b[2]);
char *a = wolfSSL_X509_notAfter(x509);
Log_Debug("not after:%s\n\r", &a[2]);
wolfSSL_X509_free(x509);
}
}
prints out (tenant ID changed)
subject name:
issuer name:/C=US/ST=Washington/L=Redmond/O=Microsoft Corporation/CN=tenanit-id-id-id
not before:201119111252Z
not after:201120121252Z