summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2017-07-24 15:07:48 +1000
committerDamien George <damien.p.george@gmail.com>2017-07-24 15:08:59 +1000
commit513dfcf4fe3277fa1cb1e383db0b60e4a3fc843b (patch)
tree1dd7e840ae34db522e0a783e5a9f192fdf411076
parentd003daee06d0547c496169fcc306ed82082e34be (diff)
downloadmicropython-513dfcf4fe3277fa1cb1e383db0b60e4a3fc843b.tar.gz
micropython-513dfcf4fe3277fa1cb1e383db0b60e4a3fc843b.zip
extmod/modussl_mbedtls: Support server_side mode.
To use server_side mode one must pass valid values in the "key" and "cert" parameters.
-rw-r--r--extmod/modussl_mbedtls.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/extmod/modussl_mbedtls.c b/extmod/modussl_mbedtls.c
index 40dd8c049f..ad29666ae8 100644
--- a/extmod/modussl_mbedtls.c
+++ b/extmod/modussl_mbedtls.c
@@ -128,7 +128,7 @@ STATIC mp_obj_ssl_socket_t *socket_new(mp_obj_t sock, struct ssl_args *args) {
}
ret = mbedtls_ssl_config_defaults(&o->conf,
- MBEDTLS_SSL_IS_CLIENT,
+ args->server_side.u_bool ? MBEDTLS_SSL_IS_SERVER : MBEDTLS_SSL_IS_CLIENT,
MBEDTLS_SSL_TRANSPORT_STREAM,
MBEDTLS_SSL_PRESET_DEFAULT);
if (ret != 0) {
@@ -172,15 +172,11 @@ STATIC mp_obj_ssl_socket_t *socket_new(mp_obj_t sock, struct ssl_args *args) {
assert(ret == 0);
}
- if (args->server_side.u_bool) {
- assert(0);
- } else {
- while ((ret = mbedtls_ssl_handshake(&o->ssl)) != 0) {
- if (ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE) {
- //assert(0);
- printf("mbedtls_ssl_handshake error: -%x\n", -ret);
- mp_raise_OSError(MP_EIO);
- }
+ while ((ret = mbedtls_ssl_handshake(&o->ssl)) != 0) {
+ if (ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE) {
+ //assert(0);
+ printf("mbedtls_ssl_handshake error: -%x\n", -ret);
+ mp_raise_OSError(MP_EIO);
}
}