Commit 26e4b74e authored by Jannik Hoelling's avatar Jannik Hoelling
Browse files

bearSSL strict alpn clientside

parent ad6283e4
......@@ -75,6 +75,7 @@ int main(int argc, char *argv[]) {
alpn_ptr = malloc(sizeof(char) * strlen(alpn));
alpn_ptr[0] = alpn;
br_ssl_engine_set_protocol_names(&sc.eng, alpn_ptr, 1);
br_ssl_engine_add_flags(&sc.eng, BR_OPT_FAIL_ON_ALPN_MISMATCH);
/*
* Reset the client context, for a new handshake. We provide the
......@@ -92,15 +93,7 @@ int main(int argc, char *argv[]) {
/* Strict ALPN */
const char *alpn_received = br_ssl_engine_get_selected_protocol(&sc.eng);
err = br_ssl_engine_last_error(&sc.eng);
if (alpn_received == NULL || strcmp(alpn_ptr[0], alpn_received) != 0) {
printf("Invalid ALPN received: %s\n", alpn_received);
//br_sslio_close(&ioc);
close(fd);
return 120;
} else {
printf("ALPN negotiatiated: %s\n", alpn_received);
}
printf("ALPN negotiatiated: %s\n", alpn_received);
// send message to server
//const char *message = "Hello from Client!";
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment