Use mbedtls_x509_crt_get_subject() in test_suite_x509parse test
diff --git a/tests/suites/test_suite_x509parse.function b/tests/suites/test_suite_x509parse.function
index 91aa696..de0bc6d 100644
--- a/tests/suites/test_suite_x509parse.function
+++ b/tests/suites/test_suite_x509parse.function
@@ -24,17 +24,6 @@
     1024,
 };
 
-static void x509_free_name( mbedtls_x509_name *name )
-{
-    while( name != NULL )
-    {
-        mbedtls_x509_name *next = name->next;
-        mbedtls_platform_zeroize( name, sizeof( *name ) );
-        mbedtls_free( name );
-        name = next;
-    }
-}
-
 /* Profile for backward compatibility. Allows SHA-1, unlike the default
    profile. */
 const mbedtls_x509_crt_profile compat_profile =
@@ -154,24 +143,17 @@
     char *p = ctx->p;
     size_t n = ctx->buf + sizeof( ctx->buf ) - ctx->p;
     mbedtls_x509_crt_frame *frame;
-    mbedtls_x509_name subject;
+    mbedtls_x509_name *subject;
     ((void) flags);
 
+    ret = mbedtls_x509_crt_get_subject( crt, &subject );
+    if( ret != 0 )
+        return( ret );
+
     ret = mbedtls_x509_crt_frame_acquire( crt, &frame );
     if( ret != 0 )
         return( ret );
 
-    /* Get linked list presentation of issuer which
-     * `mbedtls_x509_dn_gets()` understands. */
-    {
-        unsigned char *subject_start = frame->subject_raw.p;
-        unsigned char *subject_end = frame->subject_raw.p + frame->subject_raw.len;
-
-        ret = mbedtls_x509_get_name( &subject_start, subject_end, &subject );
-        if( ret != 0 )
-            goto cleanup;
-    }
-
     ret = mbedtls_snprintf( p, n, "depth %d - serial ", certificate_depth );
     MBEDTLS_X509_SAFE_SNPRINTF_WITH_ERROR;
 
@@ -186,7 +168,7 @@
     ret = mbedtls_snprintf( p, n, " - subject " );
     MBEDTLS_X509_SAFE_SNPRINTF_WITH_ERROR;
 
-    ret = mbedtls_x509_dn_gets( p, n, &subject );
+    ret = mbedtls_x509_dn_gets( p, n, subject );
     MBEDTLS_X509_SAFE_SNPRINTF_WITH_ERROR;
 
     ret = mbedtls_snprintf( p, n, " - flags 0x%08x\n", *flags );
@@ -196,7 +178,7 @@
 
 cleanup:
 
-    x509_free_name( subject.next );
+    mbedtls_x509_name_free( subject );
     mbedtls_x509_crt_frame_release( crt, frame );
 
     if( ret < 0 )