@@ -1103,7 +1103,7 @@ static int ClientWriteRead(WOLFSSL* ssl, const char* msg, int msgSz,
11031103/* 4. add the same message into Japanese section */
11041104/* (will be translated later) */
11051105/* 5. add printf() into suitable position of Usage() */
1106- static const char * client_usage_msg [][75 ] = {
1106+ static const char * client_usage_msg [][78 ] = {
11071107 /* English */
11081108 {
11091109 " NOTE: All files relative to wolfSSL home dir\n" , /* 0 */
@@ -1318,9 +1318,13 @@ static const char* client_usage_msg[][75] = {
13181318#ifndef NO_PSK
13191319 "--openssl-psk Use TLS 1.3 PSK callback compatible with OpenSSL\n" , /* 74 */
13201320#endif
1321+ #ifdef HAVE_RPK
1322+ "--rpk Use RPK for the defined certificates\n" , /* 75 */
1323+ #endif
1324+ "--files-are-der Specified files are in DER, not PEM format\n" , /* 76 */
13211325 "\n"
13221326 "For simpler wolfSSL TLS client examples, visit\n"
1323- "https://github.com/wolfSSL/wolfssl-examples/tree/master/tls\n" , /* 75 */
1327+ "https://github.com/wolfSSL/wolfssl-examples/tree/master/tls\n" , /* 77 */
13241328 NULL ,
13251329 },
13261330#ifndef NO_MULTIBYTE_PRINT
@@ -1542,10 +1546,14 @@ static const char* client_usage_msg[][75] = {
15421546#ifndef NO_PSK
15431547 "--openssl-psk Use TLS 1.3 PSK callback compatible with OpenSSL\n" , /* 74 */
15441548#endif
1549+ #ifdef HAVE_RPK
1550+ "--rpk Use RPK for the defined certificates\n" , /* 75 */
1551+ #endif
1552+ "--files-are-der Specified files are in DER, not PEM format\n" , /* 76 */
15451553 "\n"
15461554 "より簡単なwolfSSL TLS クライアントの例については"
15471555 "下記にアクセスしてください\n"
1548- "https://github.com/wolfSSL/wolfssl-examples/tree/master/tls\n" , /* 75 */
1556+ "https://github.com/wolfSSL/wolfssl-examples/tree/master/tls\n" , /* 77 */
15491557 NULL ,
15501558 },
15511559#endif
@@ -1763,19 +1771,24 @@ static void Usage(void)
17631771 printf ("%s" , msg [++ msgid ]); /* Examples repo link */
17641772#ifdef HAVE_PQC
17651773 printf ("%s" , msg [++ msgid ]); /* --pqc */
1766- printf ( "%s" , msg [ ++ msgid ]); /* --pqc options */
1767- printf ( "%s" , msg [ ++ msgid ]); /* more --pqc options */
1768- printf ("%s" , msg [++ msgid ]); /* more --pqc options */
1774+ #endif
1775+ #ifdef WOLFSSL_SRTP
1776+ printf ("%s" , msg [++ msgid ]); /* dtls-srtp */
17691777#endif
17701778#ifdef WOLFSSL_SYS_CA_CERTS
17711779 printf ("%s" , msg [++ msgid ]); /* --sys-ca-certs */
17721780#endif
17731781#ifdef HAVE_SUPPORTED_CURVES
17741782 printf ("%s" , msg [++ msgid ]); /* --onlyPskDheKe */
17751783#endif
1776- #ifdef WOLFSSL_SRTP
1777- printf ("%s" , msg [++ msgid ]); /* dtls-srtp */
1784+ #ifndef NO_PSK
1785+ printf ("%s" , msg [++ msgid ]); /* --openssl-psk */
17781786#endif
1787+ #ifdef HAVE_RPK
1788+ printf ("%s" , msg [++ msgid ]); /* --rpk */
1789+ #endif
1790+ printf ("%s" , msg [++ msgid ]); /* --files-are-der */
1791+ printf ("%s" , msg [++ msgid ]); /* Documentation Hint */
17791792}
17801793
17811794#ifdef WOLFSSL_SRTP
@@ -1919,6 +1932,10 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
19191932 { "openssl-psk" , 0 , 265 },
19201933#endif
19211934 { "quieter" , 0 , 266 },
1935+ #ifdef HAVE_RPK
1936+ { "rpk" , 0 , 267 },
1937+ #endif /* HAVE_RPK */
1938+ { "files-are-der" , 0 , 268 },
19221939 { 0 , 0 , 0 }
19231940 };
19241941#endif
@@ -2059,6 +2076,10 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
20592076 int useDtlsCID = 0 ;
20602077 char dtlsCID [DTLS_CID_BUFFER_SIZE ] = { 0 };
20612078#endif /* WOLFSSL_DTLS_CID */
2079+ #ifdef HAVE_RPK
2080+ int useRPK = 0 ;
2081+ #endif /* HAVE_RPK */
2082+ int fileFormat = WOLFSSL_FILETYPE_PEM ;
20622083
20632084 char buffer [WOLFSSL_MAX_ERROR_SZ ];
20642085
@@ -2767,6 +2788,14 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
27672788 case 266 :
27682789 quieter = 1 ;
27692790 break ;
2791+ case 267 :
2792+ #ifdef HAVE_RPK
2793+ useRPK = 1 ;
2794+ #endif /* HAVE_RPK */
2795+ break ;
2796+ case 268 :
2797+ fileFormat = WOLFSSL_FILETYPE_ASN1 ;
2798+ break ;
27702799 default :
27712800 Usage ();
27722801 XEXIT_T (MY_EX_USAGE );
@@ -3140,6 +3169,21 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
31403169 }
31413170#endif
31423171
3172+ #ifdef HAVE_RPK
3173+ if (useRPK ) {
3174+ char ctype [] = {WOLFSSL_CERT_TYPE_RPK };
3175+ char stype [] = {WOLFSSL_CERT_TYPE_RPK };
3176+
3177+ wolfSSL_CTX_set_client_cert_type (ctx , ctype , sizeof (ctype )/sizeof (ctype [0 ]));
3178+ wolfSSL_CTX_set_server_cert_type (ctx , stype , sizeof (stype )/sizeof (stype [0 ]));
3179+ usePsk = 0 ;
3180+ #ifdef HAVE_CRL
3181+ disableCRL = 1 ;
3182+ #endif
3183+ doPeerCheck = 0 ;
3184+ }
3185+ #endif /* HAVE_RPK */
3186+
31433187 if (usePsk ) {
31443188#ifndef NO_PSK
31453189 const char * defaultCipherList = cipherList ;
@@ -3272,7 +3316,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
32723316 WOLFSSL_FILETYPE_ASN1 ) != WOLFSSL_SUCCESS )
32733317 err_sys ("can't load client cert buffer" );
32743318 #elif !defined(TEST_LOAD_BUFFER )
3275- if (wolfSSL_CTX_use_certificate_chain_file (ctx , ourCert )
3319+ if (wolfSSL_CTX_use_certificate_chain_file_format (ctx , ourCert , fileFormat )
32763320 != WOLFSSL_SUCCESS ) {
32773321 wolfSSL_CTX_free (ctx ); ctx = NULL ;
32783322 err_sys ("can't load client cert file, check file and run from"
@@ -3296,7 +3340,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
32963340 sizeof_client_key_der_2048 , SSL_FILETYPE_ASN1 ) != WOLFSSL_SUCCESS )
32973341 err_sys ("can't load client private key buffer" );
32983342 #elif !defined(TEST_LOAD_BUFFER )
3299- if (wolfSSL_CTX_use_PrivateKey_file (ctx , ourKey , WOLFSSL_FILETYPE_PEM )
3343+ if (wolfSSL_CTX_use_PrivateKey_file (ctx , ourKey , fileFormat )
33003344 != WOLFSSL_SUCCESS ) {
33013345 wolfSSL_CTX_free (ctx ); ctx = NULL ;
33023346 err_sys ("can't load client private key file, check file and run "
@@ -3593,7 +3637,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
35933637 err_sys ("can't load client cert buffer" );
35943638 }
35953639 #elif !defined(TEST_LOAD_BUFFER )
3596- if (wolfSSL_use_certificate_chain_file (ssl , ourCert )
3640+ if (wolfSSL_use_certificate_chain_file_format (ssl , ourCert , fileFormat )
35973641 != WOLFSSL_SUCCESS ) {
35983642 wolfSSL_CTX_free (ctx ); ctx = NULL ;
35993643 err_sys ("can't load client cert file, check file and run from"
@@ -3614,7 +3658,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
36143658 sizeof_client_key_der_2048 , SSL_FILETYPE_ASN1 ) != WOLFSSL_SUCCESS )
36153659 err_sys ("can't load client private key buffer" );
36163660 #elif !defined(TEST_LOAD_BUFFER )
3617- if (wolfSSL_use_PrivateKey_file (ssl , ourKey , WOLFSSL_FILETYPE_PEM )
3661+ if (wolfSSL_use_PrivateKey_file (ssl , ourKey , fileFormat )
36183662 != WOLFSSL_SUCCESS ) {
36193663 wolfSSL_CTX_free (ctx ); ctx = NULL ;
36203664 err_sys ("can't load client private key file, check file and run "
0 commit comments