2 years, 4 months ago.

mbed-http compile fail

The mbed-http library https://os.mbed.com/teams/sandbox/code/mbed-http/ fails when I try to use HTTPS. Specifically, https_request.h

    HttpsRequest(NetworkInterface* net_iface,
                 const char* ssl_ca_pem,
                 http_method method,
                 const char* url,
                 Callback<void(const char *at, uint32_t length)> body_callback = 0)

results in "Undefined symbol mbed_ctr_drbg_free".

Are there configuration items that I am missing? Is there another HTTP library that supports HTTPS that is recommended?

1 Answer

2 years, 4 months ago.

Hi Peter,

You may be missing a few configuration items. Are you using the Mbed CLI or the online compiler? If you are using the Mbed CLI you can follow the steps below to create a new Mbed HTTPS project and build successfully (the following is also adapted from the http-example here):

  1. mbed new https-example
  2. cd https-example
  3. mbed add https://os.mbed.com/teams/sandbox/code/mbed-http/
  4. mbed add https://github.com/ArmMbed/easy-connect/
  5. Create a main.cpp file in your root project directory
  6. Create a mbed_app.json file in your root project directory for the Easy Connect library
  7. Copy/paste the contents of the HTTPS example program into your main.cpp file: https://gist.github.com/yennster/ae97f2ebc14b836b4f531a2fc0470313
  8. Copy/paste the contents of the following file into your mbed_app.json file: https://gist.github.com/yennster/75933bef3fe94801917e6a3839faf31f
  9. Within mbed_app.json under config > network-interface > value, replace "ETHERNET" with your board's network connectivity option
  10. Now compile: mbed compile -t <your toolchain> -m <your board> in my case I used the following command: mbed compile -t gcc_arm -m k64f
  11. You should be able to compile successfully and now you can click and drag the created .bin file to your board

Then you can alter the main.cpp for your purposes!

Please let me know if you have any questions!

- Jenny, team Mbed

If this solved your question, please make sure to click the "Thanks" link below!

Accepted Answer

I'm using the online compiler, but I followed the corresponding steps to create a new project. Still produces the same error.

posted by Peter Miller 05 Sep 2018

Hi Peter, have you updated to the latest version of Mbed OS?

- Jenny, team Mbed

posted by Jenny Plunkett 05 Sep 2018

Yes, I've updated all the libraries.

posted by Peter Miller 05 Sep 2018

Which network interface are you using and which target board?

- Jenny, team Mbed

posted by Jenny Plunkett 05 Sep 2018

C027, CELLULAR_ONBOARD. ETHERNET fails to compile the same way.

posted by Peter Miller 05 Sep 2018

Hi, please try the following steps:

  1. Import the following example into your online compiler: https://os.mbed.com/teams/sandbox/code/http-example/
  2. Delete the easy-connect library from the http-example program and re-add it with the following URL: https://github.com/ARMmbed/easy-connect/
  3. Right click on the mbed-os library and select "Update..."
  4. Change the network-interface in mbed_app.json to "CELLULAR_ONBOARD"
  5. In the source folder open select-demo.h and change the #define DEMO to #define DEMO DEMO_HTTPS
  6. Make sure you have selected the u-blox C027 target in the top right corner
  7. Then click "Compile" and you should successfully download the .bin file for the https example

Please let me know if this works for you!

- Jenny, team Mbed

posted by Jenny Plunkett 05 Sep 2018

The last set of instructions succeeds. How do I apply this to my code? I'm trying to use mbed-http without using easy-connect as I only want to use a cell modem and don't need all those other interfaces. I basically created my main.cpp by copying main-https.cpp from that same example project, then replaced

NetworkInterface* network = easy_connect(true);

with

network = CellularBase::get_default_instance();

Do I have to use easy-connect to make mbed-http work?

posted by Peter Miller 05 Sep 2018

Hi again Peter,

Glad that succeeded for you. What I would recommend next is to investigate how the easy connect library implements the "CELLULAR_ONBOARD" connection present in the Mbed OS library. Specifically you'll want to implement the network connection code present in easy-connect.cpp.

Please let me know if you have any questions!

- Jenny, team Mbed

posted by Jenny Plunkett 05 Sep 2018

I think that's what I did to figure out how to implement the cellular-only version in the first place. I'll examine that further, but two things to consider:

1. My code works perfectly fine if I use HttpRequest() from mbed-http. The compiler failure occurs with HttpsRequest(). 2. The error is a missing symbol which seems to be from tls_socket.h. There doesn't seem to be any relation with creating a cellular network instance.

posted by Peter Miller 05 Sep 2018

Think I solved it. I was missing mbedctls_config.h and mbedtls_entropy_config.h

posted by Peter Miller 05 Sep 2018

Great! I'll make sure that gets documented in the mbed-http library.

- Jenny, team Mbed

posted by Jenny Plunkett 05 Sep 2018