Hello,
I am trying to incorporate Mutual Authentication TLS in my hardware. For testing the mutual authentication in TLS, I setup a demo service which would request a client certificate in the TLS handshake. I used MS Edge, Google Chrome to test whether the service requests a client certificate during the TLS 1.2 handshake. When I ping the website, I do receive a request for a client certificate as shown in the image below. On selecting a certificate, I am able to access the website.
Link to the demo service: https://serviceforsomsecurity.azurewebsites.net/
[A screenshot of a cell phone Description automatically generated]
The above validates that the service requires the client to provide the client certificate during the TLS handshake.
Now, when I test this with the sample mbedTLS ssl_client2.c program: https://github.com/ARMmbed/mbedtls/blob/development/programs/ssl/ssl_client…, the client does not send a certificate at all.
The following are the steps that I carry out to test the TLS connection with my service with the sample mbedTLS ssl_client2.exe :
1. Open the mbedTLS.sln and build the ssl_client2 project. This creates a ssl_client2.exe under the Debug folder.
2. ssl_client2.exe server_name=serviceforsomsecurity.azurewebsites.net server_port=443 debug_level=3 auth_mode=required reconnect=1 crt_file=cert.pem key_file=key.pem ca_file=Digicert.cer force_version=tls1_2
The above command to test whether the client sends the client certificate during handshake. Here's the log:
[A screenshot of a computer Description automatically generated]
As you can see, in 3025 client receives: got no certificate request and then followed by server hello done at 3157. And then at 2080 & 2094, client skips writing certificate; during this handshake.
3. Then I tried including renegotiation flag:
ssl_client2.exe server_name=serviceforsomsecurity.azurewebsites.net server_port=443 debug_level=3 auth_mode=required reconnect=1 crt_file=cert.pem key_file=key.pem ca_file=Digicert.cer force_version=tls1_2 renegotiate=1
Even in this case, the client does not get the certificate and abruptly ends during renegotiation due to timeout.
I have included both the log files below for complete handshake review. [ssl_client_without_renegotiation.txt and ssl_client_with_renegotiation.txt]
Can you please let me know how to debug this client certificate problem? It will be really a great help!
Million thanks in advance.
Regards,
Abhilash
Hello Sir/Madam,
I work in Espressif Systems. I am currently working on providing an alternate hardware RSA sign implementation for mbedtls software sign for Espressif's new chip ESP32S2. I have gone through mbedTLS API in detail but I dont see any option where I can only replace mbedTLS software sign function with our hardware sign function .
I have gone through the issue https://tls.mbed.org/discussions/generic/using-an-external-rsa-private-key I have seen that there is a function named `mbedtls_pk_setup_rsa_alt` where we only register private key related function to the ALT_CTX which mbedtls uses to perform RSA sign. but this is not supported for TLS connections.
I have seen that there is MBEDTLS_RSA_ALT option in mbedTLS where we can provide alternate function to many of mbedTLS API, but we do not want to change any of the other functions, just provide alternate implementation of hardware sign. If we go with this way, there will be lot of duplicate code which will be needed to be maintained.
can mbedTLS provide option to use mbedtls_rsa_alt context in its file `pkparse.c` so as to allow rsa sign using an extrnal private key.
Thanks and Regards,
Aditya
P.S. - I raised the same issue yesterday, my issue was rejected stating I have not subscribed to the mailing-list. But I had already done that. I tried to subscribe again and it also said you are already subscribed.
These defines are needed when the platform doesn’t have standard functions like `calloc()` and `free()`. (You can find more details on the macros in `config.h`.)
Regards,
Janos
From: mbed-tls <mbed-tls-bounces(a)lists.trustedfirmware.org> on behalf of songwei fu via mbed-tls <mbed-tls(a)lists.trustedfirmware.org>
Reply to: "songwei.fu(a)web.de" <songwei.fu(a)web.de>
Date: Wednesday, 17 June 2020 at 13:41
To: "Kaul, Martin" <Martin.Kaul(a)leuze.com>
Cc: "mbed-tls(a)lists.trustedfirmware.org" <mbed-tls(a)lists.trustedfirmware.org>
Subject: Re: [mbed-tls] Link error when calling "altcp_tls_create_config_client"
Thanks Martin.
It solved my problem! By adding $(CHIBIOS)/os/various/syscalls.c in the makefile and removing following defines, the linker error is gone.
#define MBEDTLS_PLATFORM_C
#define MBEDTLS_PLATFORM_MEMORY
#define MBEDTLS_PLATFORM_CALLOC_MACRO chHeapAlloc
#define MBEDTLS_PLATFORM_FREE_MACRO chHeapFree
Now I wonder when these defines are needed? I thought I need to port them to the OS-specific memory allocation. like in freeRTOS, it would be "pvPortCalloc", and for chibios it would be chHeapAlloc. Anybody can give me some hint?
-- Songwei
Gesendet: Mittwoch, 17. Juni 2020 um 12:12 Uhr
Von: "Kaul, Martin" <Martin.Kaul(a)leuze.com>
An: "songwei.fu(a)web.de" <songwei.fu(a)web.de>
Betreff: AW: [mbed-tls] Link error when calling "altcp_tls_create_config_client"
Hi,
_sbrk is need when you using heap memory, for example using malloc() – see following discussion in stackoverflow: https://stackoverflow.com/questions/32446814/undefined-reference-to-sbrk-in…
Maybe that helps.
Best regards
Martin
Von: mbed-tls [mailto:mbed-tls-bounces@lists.trustedfirmware.org] Im Auftrag von songwei fu via mbed-tls
Gesendet: Mittwoch, 17. Juni 2020 11:49
An: mbed-tls(a)lists.trustedfirmware.org
Betreff: [mbed-tls] Link error when calling "altcp_tls_create_config_client"
Hi guys,
I am new to the list and also to mbedTLS. Now I am trying to port mbedTLS to chibiOS. And when I called altcp_tls_create_config_client(cert, sizeof(cert)), I got a link error like following:
c:/chibistudio/tools/gnu tools arm embedded/7.0 2017q4/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v7e-m\libg.a(lib_a-sbrkr.o): In function `_sbrk_r':
sbrkr.c:(.text._sbrk_r+0xc): undefined reference to `_sbrk'
And these are my settings:
#define MBEDTLS_PLATFORM_C
#define MBEDTLS_PLATFORM_MEMORY
#define MBEDTLS_PLATFORM_CALLOC_MACRO chHeapAlloc
#define MBEDTLS_PLATFORM_FREE_MACRO chHeapFree
where chHeapAlloc and chHeapFree are the memory allocation functions from chibios.
(1) Did I miss some settings? or i did something wrong?
(2) I did not find much information about the porting from chibios side. Does anybody know where I can look for reference projects/docs?
Any suggestion will be appreciated. Thanks.
Songwei
Hi Songwei,
Welcome to the list and thank you for your interest in Mbed TLS!
I found a similar issue on stack overflow:
https://stackoverflow.com/questions/28895703/sbrk-function-not-found-when-p…
Is this the same issue as yours?
Regards,
Janos
From: mbed-tls <mbed-tls-bounces(a)lists.trustedfirmware.org> on behalf of songwei fu via mbed-tls <mbed-tls(a)lists.trustedfirmware.org>
Reply to: "songwei.fu(a)web.de" <songwei.fu(a)web.de>
Date: Wednesday, 17 June 2020 at 10:49
To: "mbed-tls(a)lists.trustedfirmware.org" <mbed-tls(a)lists.trustedfirmware.org>
Subject: [mbed-tls] Link error when calling "altcp_tls_create_config_client"
Hi guys,
I am new to the list and also to mbedTLS. Now I am trying to port mbedTLS to chibiOS. And when I called altcp_tls_create_config_client(cert, sizeof(cert)), I got a link error like following:
c:/chibistudio/tools/gnu tools arm embedded/7.0 2017q4/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v7e-m\libg.a(lib_a-sbrkr.o): In function `_sbrk_r':
sbrkr.c:(.text._sbrk_r+0xc): undefined reference to `_sbrk'
And these are my settings:
#define MBEDTLS_PLATFORM_C
#define MBEDTLS_PLATFORM_MEMORY
#define MBEDTLS_PLATFORM_CALLOC_MACRO chHeapAlloc
#define MBEDTLS_PLATFORM_FREE_MACRO chHeapFree
where chHeapAlloc and chHeapFree are the memory allocation functions from chibios.
(1) Did I miss some settings? or i did something wrong?
(2) I did not find much information about the porting from chibios side. Does anybody know where I can look for reference projects/docs?
Any suggestion will be appreciated. Thanks.
Songwei
Hi All,
I am working on Renesas RZA2M embedded board with Linux. It has limited memory of 6MB flash(R-Only)
I am using mbedtls version 2.16.5 for aws iot sdk for embedded c according to
https://docs.aws.amazon.com/iot/latest/developerguide/iot-embedded-c-sdk.ht…
When I run sample application, it is taking 15 secs for "Seeding random generator number..." and throwing below error
$ ./subscribe_publish_sample
AWS IoT SDK Version 3.0.1-
DEBUG: main L#159 rootCA /root/../certs/AmazonRootCA1.pem
DEBUG: main L#160 clientCRT /root/../certs/774a17950a-certificate.pem.crt
DEBUG: main L#161 clientKey /root/../certs/774a17950a-private.pem.key
Connecting...
DEBUG: iot_tls_connect L#130
. Seeding the random number generator...
DEBUG: iot_tls_connect L#138 . Loading the CA root certificate ...
DEBUG: iot_tls_connect L#144 ok (0 skipped)
DEBUG: iot_tls_connect L#146 . Loading the client cert. and key...
DEBUG: iot_tls_connect L#159 ok
DEBUG: iot_tls_connect L#161 . Connecting to a2g7twmqo7hg82-ats.iot.ap-south-1.amazonaws.com/443...
DEBUG: iot_tls_connect L#180 ok
DEBUG: iot_tls_connect L#182 . Setting up the SSL/TLS structure...
DEBUG: iot_tls_connect L#223
SSL state connect : 0
DEBUG: iot_tls_connect L#226 ok
DEBUG: iot_tls_connect L#228
SSL state connect : 0
DEBUG: iot_tls_connect L#229 . Performing the SSL/TLS handshake...
ERROR: iot_tls_connect L#232 failed
! mbedtls_ssl_handshake returned -0x50
ERROR: main L#190 Error(-4) connecting to a2g7twmqo7hg82-ats.iot.ap-south-1.amazonaws.com:443
For detailed debug log using ssl_client2, go through https://pastebin.com/mNXhB0xj<https://github.com/ARMmbed/mbedtls/issues/url>
https://pastebin.com/mNXhB0xj
my client device specifications
$ cat /proc/cpuinfo
processor : 0
model name : ARMv7 Processor rev 1 (v7l)
BogoMIPS : 1056.00
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpd32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x4
CPU part : 0xc09
CPU revision : 1
Hardware : Generic R7S9210 (Flattened Device Tree)
Revision : 0000
Serial : 0000000000000000
$ free
total used free shared buffers cached
Mem: 7544 4484 3060 40 0 304
-/+ buffers/cache: 4180 3364
Swap: 0 0 0
I am not getting any help to resolve this issue and spending days and days. I am suspecting the issue might be timing related (or) cpu clock related (or) memory footprint related (or) something else
I need this forum help badly to resolve the issue. Please ping me if you need any other data.
Thanks in advance,
Srinivas.
Regards,
Srinivas.
[cid:1eddf249-06f8-4cbd-a3e2-9c22437fd27f]
Hi,
I wanted to use TLS over BLE application. When I googled, I figured out that MbedTLS can work on BLE. If someone can share a sample application where-in MbedTLS APIs are used as part of a BT/BLE application, it will be of great help.
Regards,
Fariya
Hi,
we have an application which uses ASIO. And now we want to add mbed TLS to
provide a TLS layer.
ASIO can be used with OpenSSL and wolfSSL. But how to do this with mbed TLS?
Any hints on that?
See also this question at SO:
https://stackoverflow.com/questions/61875404/asio-c-with-mbed-tls-library
best regards,
Frank