examples/tls_client: support client key authentication
authorJunyeon LEE <junyeon2.lee@samsung.com>
Mon, 10 Apr 2017 08:42:55 +0000 (17:42 +0900)
committerHeesub Shin <heesub.shin@samsung.com>
Tue, 18 Apr 2017 03:02:14 +0000 (12:02 +0900)
This commit adds key parsing routine in client example. Because
sometimes server requires client's signature for authentication.

Change-Id: Iddcf87417bac0e4eba092df845ee20b00597fad5
Signed-off-by: Junyeon LEE <junyeon2.lee@samsung.com>
apps/examples/tls_client/tls_client_main.c

index 9b7fe2b..867db82 100644 (file)
@@ -925,7 +925,7 @@ usage:
        mbedtls_printf(" ok (%d skipped)\n", ret);
 
        /*
-        * 1.2. Load own certificate
+        * 1.2. Load own certificate and key
         */
        mbedtls_printf("  . Loading the own cert...");
        fflush(stdout);
@@ -938,6 +938,15 @@ usage:
 
        mbedtls_printf(" ok\n");
 
+       mbedtls_printf("  . Loading the Private Key...");
+       fflush(stdout);
+
+       if ((ret = mbedtls_pk_parse_key(&pkey, (const unsigned char *) mbedtls_test_cli_key_rsa, mbedtls_test_cli_key_rsa_len, NULL, 0)) != 0)
+       {
+               mbedtls_printf(" failed\n  !  mbedtls_pk_parse_key returned %d\n\n", ret);
+               goto exit;
+       }
+
        /*
         * 2. Start the connection
         */