forked from atomvm/AtomVM
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add minimal support for ssl module using Mbed TLS and sockets
Add support for ssl client in binary and passive modes, with no certificate verification Add APIs to otp_socket so it can be called from ssl bio callbacks Fix a bug in lwIP otp_socket's recv revealed by ssl tests Fix a bug in BSD otp_socket's recvfrom revealed by refactoring Fix a bug in esp32 tests where main context and its resoures were not properly destroyed Update documentation and workflows to reflect the requirement on Mbed TLS Fix exported types of inet module Signed-off-by: Paul Guyot <[email protected]>
- Loading branch information
Showing
36 changed files
with
2,138 additions
and
221 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# | ||
# This file is part of AtomVM. | ||
# | ||
# Copyright 2019 Riccardo Binetti <[email protected]> | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later | ||
# | ||
|
||
# Find MbedTLS | ||
# Search for MbedTLS 2.x or 3.x and define libraries like MbedTLS 3.x does. | ||
|
||
# This script is not called FindMbedTLS.cmake because it would conflict with | ||
# installed MbedTLS 3.x | ||
|
||
# If MBEDTLS_ROOT_DIR is set, no heuristic is applied. | ||
# It must be set to the parent directory of include/mbedtls/version.h | ||
# Libraries are at ${MBEDTLS_LIBRARIES_DIR} or, if unset, ${MBEDTLS_ROOT_DIR}/lib/ | ||
|
||
# If MBEDTLS_ROOT_DIR is not set, apply the following heuristic: | ||
# Try to find mbedtls 3.x CMake package with find_package | ||
# If it doesn't work, search for MBEDTLS_VERSION_NUMBER symbol as well as | ||
# the thre libraries we need with check_symbol_exists and find_library | ||
|
||
if (MBEDTLS_ROOT_DIR) | ||
set(MbedTLS_FOUND TRUE) | ||
if (NOT MBEDTLS_LIBRARIES_DIR) | ||
set(MBEDTLS_LIBRARIES_DIR ${MBEDTLS_ROOT_DIR}/lib) | ||
endif() | ||
|
||
add_library(MbedTLS::mbedcrypto SHARED IMPORTED) | ||
set_target_properties(MbedTLS::mbedcrypto PROPERTIES | ||
IMPORTED_LOCATION "${MBEDTLS_LIBRARIES_DIR}/libmbedcrypto${CMAKE_SHARED_LIBRARY_SUFFIX}" | ||
INTERFACE_INCLUDE_DIRECTORIES "${MBEDTLS_ROOT_DIR}/include/" | ||
) | ||
|
||
add_library(MbedTLS::mbedx509 SHARED IMPORTED) | ||
set_target_properties(MbedTLS::mbedx509 PROPERTIES | ||
IMPORTED_LOCATION "${MBEDTLS_LIBRARIES_DIR}/libmbedx509${CMAKE_SHARED_LIBRARY_SUFFIX}" | ||
INTERFACE_INCLUDE_DIRECTORIES "${MBEDTLS_ROOT_DIR}/include/" | ||
INTERFACE_LINK_LIBRARIES "MbedTLS::mbedcrypto" | ||
) | ||
|
||
add_library(MbedTLS::mbedtls SHARED IMPORTED) | ||
set_target_properties(MbedTLS::mbedtls PROPERTIES | ||
IMPORTED_LOCATION "${MBEDTLS_LIBRARIES_DIR}/libmbedtls${CMAKE_SHARED_LIBRARY_SUFFIX}" | ||
INTERFACE_INCLUDE_DIRECTORIES "${MBEDTLS_ROOT_DIR}/include/" | ||
INTERFACE_LINK_LIBRARIES "MbedTLS::mbedx509" | ||
) | ||
else() | ||
# MbedTLS 3.x is installed as a CMake package | ||
find_package(MbedTLS QUIET) | ||
if (NOT MbedTLS_FOUND) | ||
include(CheckSymbolExists) | ||
check_symbol_exists(MBEDTLS_VERSION_NUMBER "mbedtls/version.h" HAVE_MBEDTLS_VERSION_NUMBER) | ||
find_library(MBEDCRYPTO mbedcrypto) | ||
find_library(MBEDX509 mbedx509) | ||
find_library(MBEDTLS mbedtls) | ||
if (HAVE_MBEDTLS_VERSION_NUMBER AND NOT MBEDCRYPTO_NOTFOUND AND NOT MBEDX509_NOTFOUND AND NOT MBEDTLS_NOTFOUND) | ||
set(MbedTLS_FOUND TRUE) | ||
add_library(MbedTLS::mbedcrypto SHARED IMPORTED) | ||
set_target_properties(MbedTLS::mbedcrypto PROPERTIES | ||
IMPORTED_LOCATION "${MBEDCRYPTO}" | ||
) | ||
|
||
add_library(MbedTLS::mbedx509 SHARED IMPORTED) | ||
set_target_properties(MbedTLS::mbedx509 PROPERTIES | ||
IMPORTED_LOCATION "${MBEDX509}" | ||
INTERFACE_LINK_LIBRARIES "MbedTLS::mbedcrypto" | ||
) | ||
|
||
add_library(MbedTLS::mbedtls SHARED IMPORTED) | ||
set_target_properties(MbedTLS::mbedtls PROPERTIES | ||
IMPORTED_LOCATION "${MBEDTLS}" | ||
INTERFACE_LINK_LIBRARIES "MbedTLS::mbedx509" | ||
) | ||
endif() | ||
endif() | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,7 @@ set(ERLANG_MODULES | |
logger_std_h | ||
proplists | ||
socket | ||
ssl | ||
string | ||
timer | ||
unicode | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.