Skip to content
This repository was archived by the owner on Jun 8, 2021. It is now read-only.

Commit ac80914

Browse files
Rearrange set_ca_root_cert and open
1 parent e96cb7f commit ac80914

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

main.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,26 +58,26 @@ int main(void)
5858
return result;
5959
}
6060

61-
TLSSocket *socket = new TLSSocket;
62-
result = socket->set_root_ca_cert(cert);
61+
printf("Connecting to ifconfig.io\n");
62+
SocketAddress addr;
63+
result = net->gethostbyname("ifconfig.io", &addr);
6364
if (result != NSAPI_ERROR_OK) {
64-
printf("Error: socket->set_root_ca_cert() returned %d\n", result);
65-
return result;
65+
printf("Error! DNS resolution for ifconfig.io failed with %d\n", result);
6666
}
67+
addr.set_port(443);
6768

69+
TLSSocket *socket = new TLSSocket;
6870
result = socket->open(net);
6971
if (result != NSAPI_ERROR_OK) {
7072
printf("Error! socket->open() returned: %d\n", result);
7173
return result;
7274
}
7375

74-
printf("Connecting to ifconfig.io\n");
75-
SocketAddress addr;
76-
result = net->gethostbyname("ifconfig.io", &addr);
76+
result = socket->set_root_ca_cert(cert);
7777
if (result != NSAPI_ERROR_OK) {
78-
printf("Error! DNS resolution for ifconfig.io failed with %d\n", result);
78+
printf("Error: socket->set_root_ca_cert() returned %d\n", result);
79+
return result;
7980
}
80-
addr.set_port(443);
8181

8282
result = socket->connect(addr);
8383
if (result != NSAPI_ERROR_OK) {

0 commit comments

Comments
 (0)