Skip to content
This repository was archived by the owner on Sep 6, 2023. It is now read-only.

Commit 513dfcf

Browse files
committed
extmod/modussl_mbedtls: Support server_side mode.
To use server_side mode one must pass valid values in the "key" and "cert" parameters.
1 parent d003dae commit 513dfcf

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

Diff for: extmod/modussl_mbedtls.c

+6-10
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ STATIC mp_obj_ssl_socket_t *socket_new(mp_obj_t sock, struct ssl_args *args) {
128128
}
129129

130130
ret = mbedtls_ssl_config_defaults(&o->conf,
131-
MBEDTLS_SSL_IS_CLIENT,
131+
args->server_side.u_bool ? MBEDTLS_SSL_IS_SERVER : MBEDTLS_SSL_IS_CLIENT,
132132
MBEDTLS_SSL_TRANSPORT_STREAM,
133133
MBEDTLS_SSL_PRESET_DEFAULT);
134134
if (ret != 0) {
@@ -172,15 +172,11 @@ STATIC mp_obj_ssl_socket_t *socket_new(mp_obj_t sock, struct ssl_args *args) {
172172
assert(ret == 0);
173173
}
174174

175-
if (args->server_side.u_bool) {
176-
assert(0);
177-
} else {
178-
while ((ret = mbedtls_ssl_handshake(&o->ssl)) != 0) {
179-
if (ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE) {
180-
//assert(0);
181-
printf("mbedtls_ssl_handshake error: -%x\n", -ret);
182-
mp_raise_OSError(MP_EIO);
183-
}
175+
while ((ret = mbedtls_ssl_handshake(&o->ssl)) != 0) {
176+
if (ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE) {
177+
//assert(0);
178+
printf("mbedtls_ssl_handshake error: -%x\n", -ret);
179+
mp_raise_OSError(MP_EIO);
184180
}
185181
}
186182

0 commit comments

Comments
 (0)