Skip to content

Commit 43332e9

Browse files
authored
small ssl fix (#311)
1 parent 5b1079a commit 43332e9

File tree

1 file changed

+33
-12
lines changed

1 file changed

+33
-12
lines changed

src/cc_helpers.cc

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2563,7 +2563,9 @@ bool construct_platform_evidence_package(string &attesting_enclave_type,
25632563
string et2("islet-attestation");
25642564
ev2->set_evidence_type(et2);
25652565
} else {
2566-
printf("%s:%d:%s: - can't add attestation\n", __FILE__, __LINE__, __func__);
2566+
printf("error %s(), line %d: - can't add attestation\n",
2567+
__func__,
2568+
__LINE__);
25672569
return false;
25682570
}
25692571

@@ -2657,6 +2659,15 @@ void print_ssl_error(int code) {
26572659
printf("%s\n", ssl_strerror(code));
26582660
}
26592661

2662+
void get_ssl_error_code_and_print() {
2663+
unsigned long err_code;
2664+
while ((err_code = ERR_get_error()) != 0) {
2665+
char err_buf[256];
2666+
ERR_error_string_n(err_code, err_buf, sizeof(err_buf));
2667+
printf("OpenSSL Error: %s\n", err_buf);
2668+
}
2669+
}
2670+
26602671
// Socket and SSL support
26612672

26622673
bool open_client_socket(const string &host_name, int port, int *soc) {
@@ -2676,7 +2687,10 @@ bool open_client_socket(const string &host_name, int port, int *soc) {
26762687

26772688
s = getaddrinfo(host_name.c_str(), port_str, &hints, &result);
26782689
if (s != 0) {
2679-
fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(s));
2690+
printf("%s() error, line %d, getaddrinfo: %s\n",
2691+
__func__,
2692+
__LINE__,
2693+
gai_strerror(s));
26802694
return false;
26812695
}
26822696

@@ -2696,7 +2710,11 @@ bool open_client_socket(const string &host_name, int port, int *soc) {
26962710
}
26972711

26982712
if (rp == NULL) {
2699-
fprintf(stderr, "Could not connect to %s:%d\n", host_name.c_str(), port);
2713+
printf("%s() line, %d, couldn't connect to %s:%d\n",
2714+
__func__,
2715+
__LINE__,
2716+
host_name.c_str(),
2717+
port);
27002718
return false;
27012719
}
27022720

@@ -2725,7 +2743,10 @@ bool open_server_socket(const string &host_name, int port, int *soc) {
27252743

27262744
s = getaddrinfo(host_name.c_str(), port_str, &hints, &result);
27272745
if (s != 0) {
2728-
fprintf(stderr, "%s: getaddrinfo: %s\n", __func__, gai_strerror(s));
2746+
printf("error %s() line, %d, getaddrinfo: %s\n",
2747+
__func__,
2748+
__LINE__,
2749+
gai_strerror(s));
27292750
return false;
27302751
}
27312752

@@ -2749,7 +2770,7 @@ bool open_server_socket(const string &host_name, int port, int *soc) {
27492770
(const char *)&reuse,
27502771
sizeof(reuse))
27512772
< 0) {
2752-
fprintf(stderr, "Can't reuse socket %s\n", __func__);
2773+
printf("%s() error, line %d, can't reuse socket\n", __func__, __LINE__);
27532774
return false;
27542775
}
27552776

@@ -2759,7 +2780,7 @@ bool open_server_socket(const string &host_name, int port, int *soc) {
27592780
(const char *)&reuse,
27602781
sizeof(reuse))
27612782
< 0) {
2762-
fprintf(stderr, "Can't reuse port %s\n", __func__);
2783+
printf("%s() error, line %d, can't reuse port\n", __func__, __LINE__);
27632784
return false;
27642785
}
27652786
#endif
@@ -2771,18 +2792,18 @@ bool open_server_socket(const string &host_name, int port, int *soc) {
27712792
}
27722793

27732794
if (rp == NULL) {
2774-
fprintf(stderr,
2775-
"%s: Could not bind to %s:%d\n",
2776-
__func__,
2777-
host_name.c_str(),
2778-
port);
2795+
printf("%s() error, line %d, could not bind to %s:%d\n",
2796+
__func__,
2797+
__LINE__,
2798+
host_name.c_str(),
2799+
port);
27792800
return false;
27802801
}
27812802

27822803
freeaddrinfo(result);
27832804

27842805
if (listen(sfd, 10) != 0) {
2785-
printf("%s: cant listen\n", __func__);
2806+
printf("%s()error, line, %d, cant listen\n", __func__, __LINE__);
27862807
return false;
27872808
}
27882809

0 commit comments

Comments
 (0)