https://github.com/JuliaLang/MbedTLS.jl
Wrapper around mbedtls
https://github.com/JuliaLang/MbedTLS.jl
Last synced: 7 months ago
JSON representation
Wrapper around mbedtls
- Host: GitHub
- URL: https://github.com/JuliaLang/MbedTLS.jl
- Owner: JuliaLang
- License: other
- Created: 2015-09-03T10:32:18.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2024-03-01T10:43:02.000Z (over 2 years ago)
- Last Synced: 2025-10-19T10:07:02.373Z (8 months ago)
- Language: Julia
- Size: 673 KB
- Stars: 41
- Watchers: 19
- Forks: 50
- Open Issues: 33
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-julia-security - MbedTLS.jl - TLS and SSL protocol implementation with certificate management. (Network Security / TLS and SSL)
- fucking-awesome-cryptography - MbedTLS.jl - Wrapper around the mbed TLS and cryptography C libary. (Frameworks and Libs / Julia)
- awesome-cryptography - MbedTLS.jl - Wrapper around the mbed TLS and cryptography C libary. (Frameworks and Libs / Julia)
README
# MbedTLS
[](https://github.com/JuliaLang/MbedTLS.jl/actions/workflows/ci.yml)
[](http://codecov.io/github/JuliaWeb/MbedTLS.jl?branch=master)
[](https://juliahub.com/ui/Packages/MbedTLS/bf9T0)
A wrapper around the [mbed](https://tls.mbed.org/) TLS and cryptography C libary.
Current supported mbedtls version: 2.16.0 (from [MbedTLS_jll.jl](https://github.com/JuliaBinaryWrappers/MbedTLS_jll.jl))
Usage:
```julia
using Sockets
sock = connect("httpbin.org", 443)
entropy = MbedTLS.Entropy()
rng = MbedTLS.CtrDrbg()
MbedTLS.seed!(rng, entropy)
ctx = MbedTLS.SSLContext()
conf = MbedTLS.SSLConfig()
MbedTLS.config_defaults!(conf)
MbedTLS.authmode!(conf, MbedTLS.MBEDTLS_SSL_VERIFY_REQUIRED)
MbedTLS.rng!(conf, rng)
function show_debug(level, filename, number, msg)
@show level, filename, number, msg
end
MbedTLS.dbg!(conf, show_debug)
MbedTLS.ca_chain!(conf)
MbedTLS.setup!(ctx, conf)
MbedTLS.set_bio!(ctx, sock)
MbedTLS.handshake(ctx)
write(ctx, "GET / HTTP/1.1\r\nHost: httpbin.org\r\n\r\n")
buf = String(read(ctx, 100))
@test ismatch(r"^HTTP/1.1 200 OK", buf)
```
Debugging with Wireshark.
MbedTLS.jl can optionally log TLS session keys in
[NSS Key Log Format](https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/Key_Log_Format).
e.g.
```julia
using HTTP
using MbedTLS
c = MbedTLS.SSLConfig(true, log_secrets="/Users/sam/stuff/secret_key_log")
HTTP.get("https://httpbin.org/ip", sslconfig=c)
```
Wireshark can be configrued to decrypt SSL traffic by setting the location
of the key log file under:
Wireshark Preferences -> Protocols -> SSL; (Pre-)Master Secret log filename.
See: https://sharkfesteurope.wireshark.org/assets/presentations17eu/15.pdf