Skip to content

Commit

Permalink
fix dtls example
Browse files Browse the repository at this point in the history
  • Loading branch information
Ichishino committed Dec 19, 2023
1 parent 7bd51ab commit 3da499b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 28 deletions.
28 changes: 0 additions & 28 deletions examples/dtls_client/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,28 +111,6 @@ app_on_tls_handshake(
}

#ifdef CO_USE_TLS

#ifndef CO_USE_WOLFSSL
// TODO
int
app_on_tls_verify_cookie(
SSL* ssl,
const unsigned char* cookie,
unsigned int cookie_len
)
{
(void)ssl;
(void)cookie;
(void)cookie_len;

printf("cookie: %*.*s\n",
cookie_len, cookie_len, (char*)cookie);

// ok
return 1;
}
#endif

int
app_on_tls_verify_peer(
int preverify_ok,
Expand All @@ -145,7 +123,6 @@ app_on_tls_verify_peer(
// ok
return 1;
}

#endif


Expand All @@ -169,11 +146,6 @@ app_tls_setup(
SSL_CTX_set_verify(
ssl_ctx, SSL_VERIFY_PEER, app_on_tls_verify_peer);

#ifndef CO_USE_WOLFSSL
// TODO
SSL_CTX_set_cookie_verify_cb(ssl_ctx, app_on_tls_verify_cookie);
#endif

tls_ctx->ssl_ctx = ssl_ctx;

#endif
Expand Down
19 changes: 19 additions & 0 deletions examples/dtls_server/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ app_on_tls_handshake(

#ifdef CO_USE_TLS
#ifndef CO_USE_WOLFSSL

// TODO
int
app_on_tls_generate_cookie(
Expand All @@ -180,6 +181,22 @@ app_on_tls_generate_cookie(

return 1;
}

// TODO
int
app_on_tls_verify_cookie(
SSL* ssl,
const unsigned char* cookie,
unsigned int cookie_len
)
{
(void)ssl;
(void)cookie;
(void)cookie_len;

return 1;
}

#endif
#endif

Expand Down Expand Up @@ -226,6 +243,8 @@ app_tls_setup(
// TODO
SSL_CTX_set_cookie_generate_cb(
ssl_ctx, app_on_tls_generate_cookie);
SSL_CTX_set_cookie_verify_cb(
ssl_ctx, app_on_tls_verify_cookie);
#endif

tls_ctx->ssl_ctx = ssl_ctx;
Expand Down

0 comments on commit 3da499b

Please sign in to comment.