The IP mode is IPv4.
1. The hostname resolves to IP address. The resolved IP address is correct (verified with a nslookup command separately).
2. setsockopt(fd, SOL_TLS, TLS_PEER_VERIFY, &verify, sizeof(verify)); is called successfully (no error returned). verify is set to NONE
3. setsockopt(fd, SOL_TLS, TLS_SEC_TAG_LIST, sec_tag_list, sizeof(sec_tag_t) * ARRAY_SIZE(sec_tag_list)); is called successfully (no error returned). sec_tag_list is initialized to { 1 }.
4. connect() returns error. Looking deeper, nrf91_connect() (in nrf/lib/bsdlib/nrf91_sockets.c::nrf91_socket_offload_connect() ) returns error -1.
I am not able to debug further than this as code is not available for bsdlibrary.
May be relevant or may be not. The port I am using is a 6443 instead of 443. I set it properly in resolve_and_connect() method.
proto = IPPROTO_TLS_1_2;
port = htons(6443);
Note: I started off with http_download_update application.