Giter VIP home page Giter VIP logo

mbedtls.jl's People

Contributors

ararslan avatar cmcaine avatar davidanthoff avatar distjubo avatar femtocleaner[bot] avatar gustafsson avatar iainnz avatar jackdunnnz avatar joshbode avatar keno avatar kmsquire avatar kpamnany avatar malmaud avatar musm avatar nsslh avatar pallharaldsson avatar quinnj avatar ranjanan avatar samoconnor avatar samuelpowell avatar sorpaas avatar staticfloat avatar stevengj avatar tanmaykm avatar tkelman avatar visr avatar vtjnash avatar wavexx avatar wildart avatar yuyichao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mbedtls.jl's Issues

`build` is failing with Ubuntu 15.04 and cmake

julia> Pkg.build("MbedTLS")
INFO: Building MbedTLS
INFO: Attempting to Create directory /home/diego/.julia/v0.4/MbedTLS/deps/downloads
INFO: Directory /home/diego/.julia/v0.4/MbedTLS/deps/downloads already created
INFO: Downloading file https://tls.mbed.org/download/mbedtls-2.1.1-apache.tgz
INFO: Done downloading file https://tls.mbed.org/download/mbedtls-2.1.1-apache.tgz
INFO: Attempting to Create directory /home/diego/.julia/v0.4/MbedTLS/deps/src
INFO: Directory /home/diego/.julia/v0.4/MbedTLS/deps/src already created
INFO: Attempting to Create directory /home/diego/.julia/v0.4/MbedTLS/deps
INFO: Directory /home/diego/.julia/v0.4/MbedTLS/deps already created
INFO: Path /home/diego/.julia/v0.4/MbedTLS/deps/src/mbedtls-2.1.1 already created
INFO: Changing Directory to /home/diego/.julia/v0.4/MbedTLS/deps/src/mbedtls-2.1.1
===============================[ ERROR: MbedTLS ]===============================

LoadError: could not spawn `cmake -DUSE_SHARED_MBEDTLS_LIBRARY=On .`: no such file or directory (ENOENT)
while loading /home/diego/.julia/v0.4/MbedTLS/deps/build.jl, in expression starting on line 68

================================================================================

==============================================================================================[ BUILD ERRORS ]===============================================================================================

WARNING: MbedTLS had build errors.

 - packages with build errors remain installed in /home/diego/.julia/v0.4
 - build the package(s) and all dependencies with `Pkg.build("MbedTLS")`
 - build a single package by running its `deps/build.jl` script

=============================================================================================================================================================================================================

julia> versioninfo()
Julia Version 0.4.1
Commit cbe1bee (2015-11-08 10:33 UTC)
Platform Info:
  System: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Core(TM) i5 CPU         750  @ 2.67GHz
  WORD_SIZE: 64
  BLAS: libopenblas (NO_LAPACKE DYNAMIC_ARCH NO_AFFINITY Nehalem)
  LAPACK: liblapack.so.3
  LIBM: libopenlibm
  LLVM: libLLVM-3.3

MbedTLS package is "dirty"

Here is the output of Pkg.status() command

5 required packages:
 - Atom                          0.5.7
 - DataFrames                    0.8.5
 - DecisionTree                  0.5.1
 - Distributions                 0.11.1
 - IJulia                        1.3.2
 - MbedTLS                       0.3.0              18dfb5cd (dirty)
 - Plots                         0.10.2
 - QuantEcon                     0.8.0
 - Stats                         0.1.0
 - StatsBase                     0.11.1
 - StatsFuns                     0.3.1
 - StochDynamicProgramming       0.2.2
 - StochasticDiffEq              0.3.0
 - Stochy                        0.0.2
 - Symata                        0.2.0
90 additional packages:
 - ASTInterpreter                0.0.4
 - AbstractTrees                 0.0.4
 - ArgParse                      0.4.0
 - AutoHashEquals                0.0.10
 - AxisAlgorithms                0.1.5
 - BinDeps                       0.4.5
 - Blink                         0.5.0
 - Blosc                         0.1.7
 - COFF                          0.0.2
 - CRC                           1.2.0
 - Calculus                      0.1.15
 - ChunkedArrays                 0.1.1
 - CodeTools                     0.4.3
 - Codecs                        0.2.0
 - ColorTypes                    0.2.12
 - Colors                        0.6.9
 - Combinatorics                 0.3.2
 - Compat                        0.9.5
 - Conda                         0.4.0
 - DSP                           0.1.1
 - DWARF                         0.1.0
 - DataArrays                    0.3.10
 - DataStructures                0.4.6
 - DiffEqBase                    0.3.2
 - ELF                           0.1.0
 - EllipsisNotation              0.0.2
 - FileIO                        0.2.0
 - FixedPointNumbers             0.2.1
 - FixedSizeArrays               0.2.5
 - ForwardDiff                   0.2.5
 - GZip                          0.2.20
 - Gallium                       0.0.4
 - HDF5                          0.7.0
 - Hiccup                        0.1.1
 - HttpCommon                    0.2.6
 - HttpParser                    0.2.0
 - HttpServer                    0.1.7
 - Interpolations                0.3.6
 - Iterators                     0.2.0
 - JLD                           0.6.7
 - JSON                          0.8.0
 - JuMP                          0.14.2
 - JuliaParser                   0.7.4
 - Juno                          0.2.5
 - LNR                           0.0.2
 - Lazy                          0.11.4
 - LegacyStrings                 0.1.1
 - LightGraphs                   0.7.2
 - LightXML                      0.4.0
 - MachO                         0.0.4
 - MacroTools                    0.3.4
 - MathProgBase                  0.5.8
 - Measures                      0.0.3
 - Media                         0.2.4
 - Mustache                      0.1.2
 - Mux                           0.2.2
 - NaNMath                       0.2.2
 - Nettle                        0.2.4
 - ObjFileBase                   0.0.4
 - PDMats                        0.5.2
 - Parameters                    0.5.0
 - ParserCombinator              1.7.11
 - PlotThemes                    0.1.0
 - PlotUtils                     0.2.0
 - Polynomials                   0.1.1
 - Primes                        0.1.1
 - ProgressMeter                 0.3.3
 - PyCall                        1.7.2
 - Ranges                        0.0.1
 - Ratios                        0.0.4
 - Reactive                      0.3.6
 - RecipesBase                   0.1.0
 - RecursiveArrayTools           0.1.1
 - Reexport                      0.0.3
 - ResettableStacks              0.0.1
 - ReverseDiffSparse             0.5.8
 - Rmath                         0.1.5
 - SHA                           0.3.0
 - ScikitLearnBase               0.2.1
 - Showoff                       0.0.7
 - SimpleTraits                  0.2.0
 - SortingAlgorithms             0.1.0
 - StructIO                      0.0.2
 - TerminalUI                    0.0.2
 - TextWrap                      0.1.6
 - URIParser                     0.1.6
 - VT100                         0.0.2
 - WebSockets                    0.2.1
 - WoodburyMatrices              0.2.1
 - ZMQ                           0.4.0

I tried Pkg.rm and Pkg.build commands but they don't work.

How to "clean" MbedTLS?

I am running julia on a manjaro linux 64-bit system

EXC_BAD_ACCESS in libmbedcrypto.0.dylib from rand!

Running the World of Julia IPython notebook causes libmbedcrypto to eventually barf, apparently on a bad RNG state.

INFO: In rand! with (rng,buf) = (MbedTLS.CtrDrbg(Ptr{Void} @0x000000030fc912a0),UInt8[0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00])
Process 38285 stopped
* thread #1: tid = 0x9bb299, 0x000000030fe16c48 libmbedcrypto.0.dylib`entropy_gather_internal + 127, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
    frame #0: 0x000000030fe16c48 libmbedcrypto.0.dylib`entropy_gather_internal + 127
libmbedcrypto.0.dylib`entropy_gather_internal:
->  0x30fe16c48 <+127>: callq  *-0x20(%rbx)
    0x30fe16c4b <+130>: testl  %eax, %eax
    0x30fe16c4d <+132>: jne    0x30fe16c92               ; <+201>
    0x30fe16c4f <+134>: movq   -0xb8(%rbp), %rcx

As far as i can tell, here is the current state of the CTR-DRBG RNG when it dies:

(lldb) x/140 0x000000030fc912a0
0x30fc912a0: 0x8afb83b8 0x79aa6172 0x1a4aae3f 0x572ab3f2
0x30fc912b0: 0x00002711 0x00000000 0x00000030 0x00000000
0x30fc912c0: 0x00002710 0x00000000 0x0000000e 0x00000000
0x30fc912d0: 0x0fc912d8 0x00000003 0xec931480 0x24c32a06
0x30fc912e0: 0x5290c048 0xfcecf511 0x658fe5e6 0x84b09009
0x30fc912f0: 0xa0f693e0 0x7b7271fb 0xe3b25422 0xc7717e24
0x30fc91300: 0x95e1be6c 0x690d4b7d 0x9c585619 0x18e8c610
0x30fc91310: 0xb81e55f0 0xc36c240b 0xc89c0416 0x0fed7a32
0x30fc91320: 0x9a0cc45e 0xf3018f23 0x9124253f 0x89cce32f
0x30fc91330: 0x31d2b6df 0xf2be92d4 0x8015aa5d 0x8ff8d06f
0x30fc91340: 0x15f41431 0xe6f59b12 0x1fc231f6 0x960ed2d9
0x30fc91350: 0xa7dc6406 0x5562f6d2 0x35e90017 0xba11d078
0x30fc91360: 0xafe5c449 0x49105f5b 0x2408fecf 0xb2062c16
0x30fc91370: 0x15da4810 0x40b8bec2 0x10e06ca9 0xaaf1bcd1
0x30fc91380: 0x05147898 0x4c0427c3 0x0dfa32e1 0xbffc1ef7
0x30fc91390: 0xaa2656e7 0xea9ee825 0x2f676712 0x8596dbc3
0x30fc913a0: 0x8082a35b 0xcc868498 0x46be6da7 0xf9427350
0x30fc913b0: 0x536425b7 0xb9facd92 0x60314aef 0xe5a7912c
0x30fc913c0: 0x65253277 0xa9a3b6ef 0x95b42378 0x6cf65028
0x30fc913d0: 0x3f92759f 0x8668b80d 0x00000000 0x00000000
0x30fc913e0: 0x00000000 0x00000000 0x0fe16cb9 0x00000003
0x30fc913f0: 0x10090e00 0x00000003 0x0132cca0 0x00000001
0x30fc91400: 0x0fc98bc8 0x00000003 0x0fc914a1 0x00000003
0x30fc91410: 0x015cbe50 0x00000001 0x0fc8f6b0 0x00000003
0x30fc91420: 0x015cbe6b 0x00000001 0x00dd1980 0x00000001
0x30fc91430: 0x00000033 0xffffffff 0x01825150 0x00000001
0x30fc91440: 0x00000000 0x00000000 0x00000000 0x00000000
0x30fc91450: 0x0fc913e0 0x00000003 0x00000003 0xffffffff
0x30fc91460: 0x00000000 0x00000000 0x00000000 0x00000000
0x30fc91470: 0x00000000 0x00000000 0x0100008a 0x001e0140
0x30fc91480: 0x0fc98e38 0x00000003 0x0fc91020 0x00000003
0x30fc91490: 0x0fc9a82a 0x00000003 0x0132cca0 0x00000001
0x30fc914a0: 0x0fc98bc8 0x00000003 0x0fc9a841 0x00000003
0x30fc914b0: 0x0146c510 0x00000001 0x0fc90f10 0x00000003
0x30fc914c0: 0x0146c52b 0x00000001 0x00dd1980 0x00000001

Start of backtrace:

(lldb) bt
* thread #1: tid = 0x9bb299, 0x000000030fe16c48 libmbedcrypto.0.dylib`entropy_gather_internal + 127, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
  * frame #0: 0x000000030fe16c48 libmbedcrypto.0.dylib`entropy_gather_internal + 127
    frame #1: 0x000000030fe16d0f libmbedcrypto.0.dylib`mbedtls_entropy_func + 86
    frame #2: 0x000000030fe0cf34 libmbedcrypto.0.dylib`mbedtls_ctr_drbg_reseed + 116
    frame #3: 0x000000030fe0d4f2 libmbedcrypto.0.dylib`mbedtls_ctr_drbg_random_with_add + 120
    frame #4: 0x00000001041f657f
    frame #5: 0x000000010001a000 libjulia-debug.dylib`jl_apply(f=0x0000000108121d90, args=0x00007fff5fbfc7f8, nargs=2) + 64 at julia.h:1269
    frame #6: 0x000000010001cb01 libjulia-debug.dylib`jl_apply_generic(F=0x0000000105fffc70, args=0x00007fff5fbfc7f8, nargs=2) + 529 at gf.c:1684

As @malmaud suggested, the problem may be that not enough memory is allocated for the RNG state here.

Build errors

I'm getting the following error while building MbedTLS.jl (as part of installing Atom.jl):

INFO: Cloning Atom from http://github.com/JunoLab/Atom.jl
INFO: Computing changes...
INFO: Installing Blink v0.3.2
INFO: Installing CodeTools v0.2.0
INFO: Installing Codecs v0.1.5
INFO: Installing Hiccup v0.0.2
INFO: Installing HttpCommon v0.2.4
INFO: Installing HttpParser v0.1.1
INFO: Installing HttpServer v0.1.5
INFO: Installing LNR v0.0.2
INFO: Installing Lazy v0.10.1
INFO: Installing MacroTools v0.2.1
INFO: Installing Media v0.1.2
INFO: Installing Mustache v0.0.14
INFO: Installing Mux v0.2.0
INFO: Installing Requires v0.2.2
INFO: Installing WebSockets v0.1.2
INFO: Building HttpParser
INFO: Building Homebrew
HEAD is now at c3438ae tmux: remove examples directory from HEAD install
HEAD is now at 4a13095 Merge pull request #85 from staticfloat/staging
INFO: Building MbedTLS
Unlinking /Users/Ty/.julia/v0.4/Homebrew/deps/usr/Cellar/mbedtls/2.1.2... 54 symlinks removed
Warning: staticfloat/juliadeps/mbedtls-2.1.2 already installed, it's just not linked
==================================================[ ERROR: MbedTLS ]===================================================

LoadError: Provider BinDeps.PackageManager failed to satisfy dependency libmbedtls
while loading /Users/Ty/.julia/v0.4/MbedTLS/deps/build.jl, in expression starting on line 69

wrong number of arguments to C function

ERROR: LoadError: LoadError: ccall: wrong number of arguments to C function
 in include_from_node1(::String) at ./loading.jl:532
 in include_from_node1(::String) at /Users/jameson/julia/usr/lib/julia/sys.dylib:?
 in include(::String) at ./sysimg.jl:14
 in include(::String) at /Users/jameson/julia/usr/lib/julia/sys.dylib:?
 in jlplt_jl_load__1006 at /Users/jameson/julia/usr/lib/julia/sys.dylib:?
 in include_from_node1(::String) at ./loading.jl:532
 in include_from_node1(::String) at /Users/jameson/julia/usr/lib/julia/sys.dylib:?
 in include(::String) at ./sysimg.jl:14
 in include(::String) at /Users/jameson/julia/usr/lib/julia/sys.dylib:?
 in macro expansion; at none:2 [inlined]
 in anonymous at <missing>:0
 in jlplt_jl_toplevel_eval_in_1247 at /Users/jameson/julia/usr/lib/julia/sys.dylib:?
 in eval(::Module, ::Any) at ./boot.jl:236
 in eval(::Module, ::Any) at /Users/jameson/julia/usr/lib/julia/sys.dylib:?
 in process_options(::Base.JLOptions) at ./client.jl:248
 in _start() at ./client.jl:335
 in _start() at /Users/jameson/julia/usr/lib/julia/sys.dylib:?
while loading /Users/jameson/.julia/v0.6/MbedTLS/src/entropy.jl, in expression starting on line 48

(JuliaLang/julia#18754 will automatically lint ccall argument list length during method definition)

[SOLVED] Build error, failed to satisfy dependency libmbedtls

I'm on Ubuntu 14.04LTS and I use Julia 0.4.6,

Linux hp8300-16 3.13.0-88-generic #135-Ubuntu SMP Wed Jun 8 21:10:42 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

When I build the package, I have the following issue :

Pkg.build("MbedTLS")
INFO: Building MbedTLS
INFO: Attempting to Create directory /home/imb/gmarqu100p/.julia/v0.4/MbedTLS/deps/downloads
INFO: Directory /home/imb/gmarqu100p/.julia/v0.4/MbedTLS/deps/downloads already created
INFO: Downloading file https://cache.julialang.org/https://tls.mbed.org/download/mbedtls-2.1.1-apache.tgz
INFO: Done downloading file https://cache.julialang.org/https://tls.mbed.org/download/mbedtls-2.1.1-apache.tgz
INFO: Attempting to Create directory /home/imb/gmarqu100p/.julia/v0.4/MbedTLS/deps/src
INFO: Directory /home/imb/gmarqu100p/.julia/v0.4/MbedTLS/deps/src already created
INFO: Attempting to Create directory /home/imb/gmarqu100p/.julia/v0.4/MbedTLS/deps
INFO: Directory /home/imb/gmarqu100p/.julia/v0.4/MbedTLS/deps already created
INFO: Path /home/imb/gmarqu100p/.julia/v0.4/MbedTLS/deps/src/mbedtls-2.1.1 already created
INFO: Changing Directory to /home/imb/gmarqu100p/.julia/v0.4/MbedTLS/deps/src/mbedtls-2.1.1
-- Configuring done
-- Generating done
-- Build files have been written to: /home/imb/gmarqu100p/.julia/v0.4/MbedTLS/deps/src/mbedtls-2.1.1
[ 36%] Built target mbedcrypto
[ 43%] Built target mbedx509
[ 50%] Built target mbedtls
[ 86%] Built target mbedcrypto_static
[ 93%] Built target mbedx509_static
[100%] Built target mbedtls_static
[100%] Built target lib
===============================[ ERROR: MbedTLS ]===============================

LoadError: Provider BinDeps.BuildProcess failed to satisfy dependency libmbedtls
while loading /home/imb/gmarqu100p/.julia/v0.4/MbedTLS/deps/build.jl, in expression starting on line 74

================================================================================

==============================================================================================[ BUILD ERRORS ]===============================================================================================

WARNING: MbedTLS had build errors.

 - packages with build errors remain installed in /home/imb/gmarqu100p/.julia/v0.4
 - build the package(s) and all dependencies with `Pkg.build("MbedTLS")`
 - build a single package by running its `deps/build.jl` script

=============================================================================================================================================================================================================

However, libraries are built

shell>  ls ~/.julia/v0.4/MbedTLS/deps/src/mbedtls-2.1.1/library/
aes.c        camellia.c           ctr_drbg.c    entropy.c         libmbedcrypto.so.0      libmbedx509.so.0      memory_buffer_alloc.c  pkcs5.c      sha256.c            ssl_tls.c           x509_crt.c
aesni.c      ccm.c                debug.c       entropy_poll.c    libmbedcrypto.so.2.1.1  libmbedx509.so.2.1.1  net.c                  pkparse.c    sha512.c            threading.c         x509_csr.c
arc4.c       certs.c              des.c         error.c           libmbedtls.a            Makefile              oid.c                  pk_wrap.c    ssl_cache.c         timing.c            x509write_crt.c
asn1parse.c  cipher.c             dhm.c         gcm.c             libmbedtls.so           md2.c                 padlock.c              pkwrite.c    ssl_ciphersuites.c  version.c           x509write_csr.c
asn1write.c  cipher_wrap.c        ecdh.c        havege.c          libmbedtls.so.10        md4.c                 pem.c                  platform.c   ssl_cli.c           version_features.c  xtea.c
base64.c     CMakeFiles           ecdsa.c       hmac_drbg.c       libmbedtls.so.2.1.1     md5.c                 pk.c                   ripemd160.c  ssl_cookie.c        x509.c
bignum.c     cmake_install.cmake  ecp.c         libmbedcrypto.a   libmbedx509.a           md.c                  pkcs11.c               rsa.c        ssl_srv.c           x509_create.c
blowfish.c   CMakeLists.txt       ecp_curves.c  libmbedcrypto.so  libmbedx509.so          md_wrap.c             pkcs12.c               sha1.c       ssl_ticket.c        x509_crl.c

MethodError on latest master

JuliaLang/julia#16731 changed pointer_to_array and now:

ERROR: MethodError: no method matching pointer_to_array(::Ptr{UInt8}, ::UInt64, ::Bool)
Closest candidates are:
  pointer_to_array{T,N}(::Ptr{T}, ::Union{Integer,Tuple{Vararg{Int64,N}},Tuple{Vararg{Integer,N}}}, ::Bool)
  pointer_to_array{T,N}(::Ptr{T}, ::Union{Integer,Tuple{Vararg{Int64,N}},Tuple{Vararg{Integer,N}}})
 in f_rng(::Ptr{Void}, ::Ptr{UInt8}, ::UInt64) at /Users/kshyatt/.julia/v0.5/MbedTLS/src/ctr_drbg.jl:23
 in macro expansion at /Users/kshyatt/.julia/v0.5/MbedTLS/src/error.jl:3 [inlined]
 in handshake(::MbedTLS.SSLContext) at /Users/kshyatt/.julia/v0.5/MbedTLS/src/ssl.jl:131
 in open_stream(::HttpCommon.Request, ::MbedTLS.SSLConfig, ::Float64, ::Nullable{URIParser.URI}, ::Nullable{URIParser.URI}) at /Users/kshyatt/.julia/v0.5/Requests/src/streaming.jl:209```

HMAC and encryption using MbedTLS.jl

Hi there,
I am implementing secure sessions which requires:

  • Cryptographically secure RNG
  • HMAC with a user-defined key
  • Encryption with a user-defined key

So far I have used MbedTLS.jl for the CSRNG and Nettle.jl for HMAC and encryption, see code examples below.

function csrng(numbytes::Integer)
    # Cyrptographically secure RNG
    entropy = MbedTLS.Entropy()
    rng     = MbedTLS.CtrDrbg()
    MbedTLS.seed!(rng, entropy)
    rand(rng, numbytes)
end

hmac_signature       = digest("sha256", secret_key, arr_uint8)    # Uses Nettle.jl
encrypted_secret_key = encrypt("AES256", symm_key, secret_key)    # Uses Nettle.jl

Ideally it would be nice to drop the dependence on Nettle.jl and use MbedTLS.jl for all crypto related functions. I've had a go but without much success.

I can get hashing working as hash(MbedTLS.SHA256, arr_uint8), but this ignores the user-defined secret key in the example above.

For encryption, again I'm not sure where the user-defined secret key comes into it...and I can't get it working anyway.

entropy = MbedTLS.Entropy()
rng     = MbedTLS.CtrDrbg()
MbedTLS.seed!(rng, entropy)

ctx = MbedTLS.PKContext()
plaintext  = "This is some plaintext"
ciphertext = zeros(UInt8, length(plaintext))
MbedTLS.encrypt!(ctx, plaintext, ciphertext, rng)    # Error is raised here: Bad input parameters to function

Are there simple fixes to my code for HMAC and encryption with a user-defined key? Or do these features not yet exist in MbedTLS.jl?

Thanks for the great work on MbedTLS.jl,
Jock

Unexpected SSL error

               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.4.0-rc1 (2015-09-09 16:07 UTC)
 _/ |\__'_|_|_|\__'_|  |
|__/                   |  x86_64-apple-darwin13.4.0

julia> Pkg.installed("Requests")
v"0.3.1"

julia> Pkg.installed("MbedTLS")
v"0.1.3"

julia> import Requests

julia> r = Requests.get("https://img.shields.io/badge/foo-var-red.svg")
ERROR: MbedTLS error code -30592: SSL - A fatal alert message was received from our peer
 [inlined code] from /Users/idunning/.julia/v0.4/MbedTLS/src/error.jl:4
 in handshake at /Users/idunning/.julia/v0.4/MbedTLS/src/ssl.jl:125
 in open_stream at /Users/idunning/.julia/v0.4/Requests/src/streaming.jl:169
 in do_stream_request at /Users/idunning/.julia/v0.4/Requests/src/Requests.jl:190
 in do_request at /Users/idunning/.julia/v0.4/Requests/src/Requests.jl:141
 in get at /Users/idunning/.julia/v0.4/Requests/src/Requests.jl:252
 in get at /Users/idunning/.julia/v0.4/Requests/src/Requests.jl:251

curl is fine with it:

IAINMAC:website idunning$ curl https://img.shields.io/badge/foo-var-red.svg
<svg xmlns="http://www.w3.org/2000/svg" width="57" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="a"><rect width="57" height="20" rx="3" fill="#fff"/></mask><g mask="url(#a)"><path fill="#555" d="M0 0h28v20H0z"/><path fill="#e05d44" d="M28 0h29v20H28z"/><path fill="url(#b)" d="M0 0h57v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="14" y="15" fill="#010101" fill-opacity=".3">foo</text><text x="14" y="14">foo</text><text x="41.5" y="15" fill="#010101" fill-opacity=".3">var</text><text x="41.5" y="14">var</text></g></svg>

Cannot instantiate RSA

I assume that this isn't meant to happen?

julia> using MbedTLS

julia> rsa = MbedTLS.RSA()
ERROR: UndefVarError: MBEDTLS_MD_MD5 not defined
 in call at C:\cygwin64\home\[REDACTED]\.julia\v0.5\MbedTLS\src\rsa.jl:5
 in eval at boot.jl:263
julia> versioninfo()
Julia Version 0.5.0-dev+1627
Commit 78bc312* (2015-12-05 20:44 UTC)
Platform Info:
  System: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i5 CPU         760  @ 2.80GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Nehalem)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.3

Build fails due to cmake_check.sh permissions

I had a build failure executing the line ./cmake_check.sh. Although I don't have the exact build output anymore, I found the issue by testing from the shell:

[micahsmith@DESKTOP-UI64NVB deps (detached*)]$ ./cmake_check.sh
-bash: ./cmake_check.sh: Permission denied
[micahsmith@DESKTOP-UI64NVB deps (detached*)]$ ll
total 260K
-rw-rw-r-- 1 micahsmith micahsmith 2.6K Sep 27 01:45 build.jl
-rw-rw-r-- 1 micahsmith micahsmith 253K Sep 27 01:45 cacert.pem
-rw-rw-r-- 1 micahsmith micahsmith  156 Sep 27 01:45 cmake_check.sh
[micahsmith@DESKTOP-UI64NVB deps (detached*)]$ chmod u+x cmake_check.sh
[micahsmith@DESKTOP-UI64NVB deps (detached*)]$ ./cmake_check.sh

The build then completed successfully. I'm not sure why the permissions were not set up correctly. If it's applicable, I am trying to build on Windows Subsystem for Linux, and sometimes permissions can be strange due to the underlying Windows filesystem.

readavailable() = [] after eof() = false

I'm debugging some code in HTTP.jl where it is assumed to be "always safe to read one byte after seeing eof return false".

The loop looks like this:

    while !eof(conn.socket)
        bytes = readavailable(conn.socket)
        @assert length(bytes) > 0
        ...
    end

When I do HTTP.post("https://httpbin.org/post"; body="hey", chunksize=2)), the assertion fails.

As a workaround I have this:

    while !eof(conn.socket)
        bytes = readavailable(conn.socket)
        if length(bytes) == 0
            @assert isa(conn.socket, MbedTLS.SSLContext)
            @assert eof(conn.socket)
            break
        end
        @assert length(bytes) > 0
        ...
    end

i.e. it looks like a read is needed in order for eof to notice that the socket is closed ?

Note: the code has comments about eof and nb_available oddness. Presumably this is related.

https://github.com/JuliaWeb/MbedTLS.jl/blob/43e1a4552063566761ea72bce47db0aee44666c8/src/ssl.jl#L223

https://github.com/JuliaWeb/MbedTLS.jl/blob/43e1a4552063566761ea72bce47db0aee44666c8/src/ssl.jl#L212

Avoid download/build if system library is already installed

MbedTLS doesn't build out of the box on my system (debian unstable), but putting that aside I already have a the system library installed and development headers available, so it should really try to use the system package as opposed to build a new version of the library.

Is there a way to do that?

CAN ANYONE HELP ME ON THIS

Processing archive: C:\Users\shoren\.julia\v0.4\MbedTLS\deps\downloads\mbedtls-2.1.1-r1.zip

Error: Can not open file as archive

===============================[ ERROR: MbedTLS ]===============================

LoadError: failed process: Process(`7z x 'C:\Users\shoren\.julia\v0.4\MbedTLS\deps\downloads\mbedtls-2.1.1-r1.zip' -y '-oC:\Users\shoren\.julia\v0.4\MbedTLS\deps'`, ProcessExited(2)) [2]
while loading C:\Users\shoren\.julia\v0.4\MbedTLS\deps\build.jl, in expression starting on line 69

================================================================================

================================[ BUILD ERRORS ]================================

WARNING: MbedTLS had build errors.

 - packages with build errors remain installed in C:\Users\shoren\.julia\v0.4
 - build the package(s) and all dependencies with `Pkg.build("MbedTLS")`
 - build a single package by running its `deps/build.jl` script

================================================================================

LoadError: ccall: could not find function mbedtls_pk_init in library libmbedtls.DLL

I was executing Pkg.test("HttpServer") and encountered following error

julia> Pkg.test("HttpServer")
INFO: Computing test dependencies for HttpServer...
INFO: Installing Requests v0.3.5
INFO: Building HttpParser
INFO: Building MbedTLS
WARNING: Could not check MbedTLS version
WARNING: Could not check MbedTLS version
WARNING: Could not check MbedTLS version
WARNING: Could not check MbedTLS version
INFO: Testing HttpServer
INFO: Recompiling stale cache file C:\Users\Administrator\.julia\lib\v0.4\HttpParser.ji for module HttpParser.
INFO: Recompiling stale cache file C:\Users\Administrator\.julia\lib\v0.4\HttpServer.ji for module HttpServer.
INFO: Recompiling stale cache file C:\Users\Administrator\.julia\lib\v0.4\MbedTLS.ji for module MbedTLS.
HttpServer utility functions:
  > `write` correctly writes data response
5 facts verified.
INFO: Recompiling stale cache file C:\Users\Administrator\.julia\lib\v0.4\Requests.ji for module Requests.
HttpServer runs
  > using HTTP protocol on 0.0.0.0:8000
Listening on 0.0.0.0:8000...
  > using HTTP protocol on 127.0.0.1:8001
Listening on 127.0.0.1:8001...
  > Testing HTTPS on port 8002
ERROR: LoadError: ccall: could not find function mbedtls_pk_init in library C:\Users\Administrator\.julia\v0.4\MbedTLS\deps\usr\bin64\libmbedtls.DLL
 in call at C:\Users\Administrator\.julia\v0.4\MbedTLS\src\pk.jl:8
while loading C:\Users\Administrator\.julia\v0.4\HttpServer\test\runtests.jl, in
 expression starting on line 25
=============================[ ERROR: HttpServer ]==============================


failed process: Process(`'C:\Users\Administrator\AppData\Local\Julia-0.4.3\bin\julia' --check-bounds=yes --code-coverage=none --color=yes 'C:\Users\Administrator\.julia\v0.4\HttpServer\test\runtests.jl'`, ProcessExited(1)) [1]

================================================================================

INFO: Removing Requests v0.3.5
ERROR: HttpServer had test errors
 in error at error.jl:21

The error seems to be from MbedTLS package, the package was unable to find mbedtls_pk_init function in libmbedtls.DLL . when I cross checked libmbedtls.DLL was located in following path C:\Users\Administrator\.julia\v0.4\MbedTLS\deps\usr\bin64\libmbedtls.DLL , maybe the version of DLL is wrong ?

I encountered this error on following configuration

OS = Windows 2008 server R2 Service Pack 1
Julia version = 0.4.3
MbedTLS.jl version = 0.2.1
HttpServer version = v"0.1.5"

I was able to reproduce this error on following configuration too

OS = Windows 10
Julia version = 0.4.3
MbedTLS.jl version = v"0.2.0"
HttpServer version = v"0.1.5"

Use newer (minor-version) mbedTLS as it has security issues resolved (or even newer major-version(?))

I looked into build.jl

and see that I could easily make a PR for 2.1.5 (I think), but maybe you would want to use 2.3.0:

https://tls.mbed.org/tech-updates/releases/mbedtls-2.3.0-2.1.5-and-1.3.17-released

I didn't look closely at the security issues, or what is new in 2.3.0 (major update I guess, and then breaks API? or just new features).

Would you tag a new version of MbedTLS.jl either way? Or is that only needed if you go with 2.3.0?

connection is not stable

I am pushing hundreds of thousands of messages to SQS, but I got this error occasionally. I can manually restart it, it works fine again, but it is annoying when to produce a lot of messages. It seems that it is due to the internet connection. It works better late in the night.

ERROR: LoadError: readcb: connection reset by peer (ECONNRESET)                                       โ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
 in yieldto(::Task, ::ANY) at ./event.jl:136                                                          โ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
 in wait() at ./event.jl:169                                                                          โ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
 in wait(::Condition) at ./event.jl:27                                                                โ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
 in wait_readnb(::TCPSocket, ::Int64) at ./stream.jl:303                                              โ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
 in readbytes!(::TCPSocket, ::Array{UInt8,1}, ::Int64) at ./stream.jl:725                             โ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
 in readbytes!(::TCPSocket, ::Array{UInt8,1}, ::UInt64) at ./stream.jl:714                            โ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
 in f_recv(::Ptr{Void}, ::Ptr{UInt8}, ::UInt64) at /usr/people/jingpeng/.julia/v0.5/MbedTLS/src/ssl.jlโ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
:103                                                                                                  โ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
 in macro expansion at /usr/people/jingpeng/.julia/v0.5/MbedTLS/src/error.jl:3 [inlined]              โ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
 in handshake(::MbedTLS.SSLContext) at /usr/people/jingpeng/.julia/v0.5/MbedTLS/src/ssl.jl:145        โ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
 in open_stream(::HttpCommon.Request, ::MbedTLS.SSLConfig, ::Float64, ::Nullable{URIParser.URI}, ::Nulโ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
lable{URIParser.URI}) at /usr/people/jingpeng/.julia/v0.5/Requests/src/streaming.jl:209               โ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
 in #do_stream_request#23(::Dict{String,String}, ::Void, ::Void, ::Void, ::Array{Requests.FileParam,1}โ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
, ::Void, ::Dict{Any,Any}, ::Bool, ::Int64, ::Array{HttpCommon.Response,1}, ::MbedTLS.SSLConfig, ::Booโ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
l, ::Bool, ::Bool, ::Nullable{URIParser.URI}, ::Nullable{URIParser.URI}, ::Requests.#do_stream_requestโ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
, ::URIParser.URI, ::String) at /usr/people/jingpeng/.julia/v0.5/Requests/src/Requests.jl:381         โ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
 in (::Requests.#kw##do_stream_request)(::Array{Any,1}, ::Requests.#do_stream_request, ::URIParser.URIโ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
, ::String) at ./<missing>:0                                                                          โ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
 in #do_request#22(::Array{Any,1}, ::Function, ::URIParser.URI, ::String) at /usr/people/jingpeng/.julโ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
ia/v0.5/Requests/src/Requests.jl:311                                                                  โ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
 in (::Requests.#kw##do_request)(::Array{Any,1}, ::Requests.#do_request, ::URIParser.URI, ::String) atโ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
 ./<missing>:0        

Build Error of MbedTLS.jl on win 7 x64 julia 0.4.2

Could you tell me how to solve this problems, please?
It has troubled me for a whole day.
Thanks.
julia> Pkg.build("MbedTLS")
INFO: Building MbedTLS
===============================[ ERROR: MbedTLS ]===============================

LoadError: No download agent available; install curl, wget, or fetch.
while loading C:\Users\digiplante.julia\v0.4\MbedTLS\deps\build.jl, in expressi
on starting on line 69

WARNING: MbedTLS had build errors.

  • packages with build errors remain installed in C:\Users\digiplante.julia\v0.4
  • build the package(s) and all dependencies with Pkg.build("MbedTLS")
  • build a single package by running its deps/build.jl script

WARNING: Could not check MbedTLS version

how to fix this warning? Juno is complaining "MbedTLS not properly installed"

julia> versioninfo()
Julia Version 0.4.5
Commit 2ac304d (2016-03-18 00:58 UTC)
Platform Info:
  System: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Xeon(R) CPU E3-1231 v3 @ 3.40GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.3

julia> Pkg.build("MbedTLS")
INFO: Building MbedTLS
WARNING: Could not check MbedTLS version: ErrorException("could not load symbol
\"mbedtls_version_get_string\"\nThe specified procedure could not be found.\r\n"
)
WARNING: Could not check MbedTLS version: ErrorException("could not load symbol
\"mbedtls_version_get_string\"\nThe specified procedure could not be found.\r\n"
)
WARNING: Could not check MbedTLS version: ErrorException("could not load symbol
\"mbedtls_version_get_string\"\nThe specified procedure could not be found.\r\n"
)
WARNING: Could not check MbedTLS version: ErrorException("could not load symbol
\"mbedtls_version_get_string\"\nThe specified procedure could not be found.\r\n"
)

SSL error code -30592

I keep getting an error while at work (which is behind a firewall), but only for specific sites:

MbedTLS error code -30592: SSL - A fatal alert message was received from our peer

Build errors on Debian Jessie (testing)

On Debian Jessie (testing), running Version 0.4.3 (2016-01-12 21:37 UTC) x86_64-linux-gnu, trying to build MbedTLS results in these errors:

$ Pkg.build("MbedTLS")
INFO: Building MbedTLS
INFO: Attempting to Create directory /home/i/.julia/v0.4/MbedTLS/deps/downloads
INFO: Directory /home/i/.julia/v0.4/MbedTLS/deps/downloads already created
INFO: Downloading file https://cache.julialang.org/https://tls.mbed.org/download/mbedtls-2.1.1-apache.tgz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (77) error setting certificate verify locations:
  CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
===============================[ ERROR: MbedTLS ]===============================

LoadError: failed process: Process(`curl -f -o /home/i/.julia/v0.4/MbedTLS/deps/downloads/mbedtls-2.1.1-apache.tgz -L https://cache.julialang.org/https://tls.mbed.org/download/mbedtls-2.1.1-apache.tgz`, ProcessExited(77)) [77]
while loading /home/i/.julia/v0.4/MbedTLS/deps/build.jl, in expression starting on line 69

================================================================================

===============================================[ BUILD ERRORS ]================================================

WARNING: MbedTLS had build errors.

 - packages with build errors remain installed in /home/i/.julia/v0.4
 - build the package(s) and all dependencies with `Pkg.build("MbedTLS")`
 - build a single package by running its `deps/build.jl` script

===============================================================================================================

Thereafter, building the single package also throws errors:

ERROR: LoadError: could not spawn `./cmake_check.sh`: no such file or directory (ENOENT)
 in _jl_spawn at ./process.jl:262
while loading /home/i/.julia/v0.4/MbedTLS/deps/build.jl, in expression starting on line 69

Thanks!

MbedTLS had build errors

Hi, I received the following build error.

julia> Pkg.build("MbedTLS")
INFO: Building MbedTLS
INFO: Attempting to Create directory /home/weijian/.julia/v0.4/MbedTLS/deps/downloads
INFO: Directory /home/weijian/.julia/v0.4/MbedTLS/deps/downloads already created
INFO: Downloading file https://tls.mbed.org/download/mbedtls-2.1.1-apache.tgz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (77) error setting certificate verify locations:
  CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
===============================[ ERROR: MbedTLS ]===============================

LoadError: failed process: Process(`curl -f -o /home/weijian/.julia/v0.4/MbedTLS/deps/downloads/mbedtls-2.1.1-apache.tgz -L https://tls.mbed.org/download/mbedtls-2.1.1-apache.tgz`, ProcessExited(77)) [77]
while loading /home/weijian/.julia/v0.4/MbedTLS/deps/build.jl, in expression starting on line 68

================================================================================

================================[ BUILD ERRORS ]================================

WARNING: MbedTLS had build errors.

 - packages with build errors remain installed in /home/weijian/.julia/v0.4
 - build the package(s) and all dependencies with `Pkg.build("MbedTLS")`
 - build a single package by running its `deps/build.jl` script

================================================================================

This is my Julia version

julia> versioninfo()
Julia Version 0.4.0
Commit 0ff703b* (2015-10-08 06:20 UTC)
Platform Info:
  System: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Core(TM) i7-3537U CPU @ 2.00GHz
  WORD_SIZE: 64
  BLAS: libopenblas (NO_LAPACK NO_LAPACKE DYNAMIC_ARCH NO_AFFINITY Sandybridge)
  LAPACK: liblapack.so.3
  LIBM: libopenlibm
  LLVM: libLLVM-3.3

Do you know how should I fix this?

Thanks

segfault

julia> using MbedTLS

julia> MbedTLS.get_version(MbedTLS.SSLContext())

signal (11): Segmentation fault: 11
while loading no file, in expression starting on line 0
mbedtls_ssl_get_version at /Users/jacobquinn/julia/usr/lib//libmbedtls.dylib (unknown line)
get_version at /Users/jacobquinn/.julia/v0.5/MbedTLS/src/ssl.jl:243
unknown function (ip: 0x109f59f42)
jl_call_method_internal at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/./julia_internal.h:189 [inlined]

Adding self-signed certificate

I'm using Requests.jl to access our internal server that uses self-signed certificate. On my Linux Mint I've installed certificate into /usr/share/ca-certificates/extra/ServerCA.crt and ran sudo dpkg-reconfigure ca-certificates as suggested in this question. Now I can make calls to our server using wget, however using Requests.jl fails with MbedTLS error:

ERROR: MbedTLS error code -9984: X509 - Certificate verification failed, e.g. CRL, CA or signature check failed
[inlined code] from /home/username/.julia/v0.4/MbedTLS/src/error.jl:4
in handshake at /home/username/.julia/v0.4/MbedTLS/src/ssl.jl:131
in open_stream at /home/username/.julia/v0.4/Requests/src/streaming.jl:209
in do_stream_request at /home/username/.julia/v0.4/Requests/src/Requests.jl:350
in do_request at /home/username/.julia/v0.4/Requests/src/Requests.jl:290
in post at /home/username/.julia/v0.4/Requests/src/Requests.jl:413
in post at /home/username/.julia/v0.4/Requests/src/Requests.jl:412
in get_token at /home/username/work/jl/DMPClient/src/core.jl:15
in call at /home/username/work/jl/DMPClient/src/core.jl:30

As far as I understand, it may be related to:

  1. Incorrect installation of certificate. In this case it's not actually related to this repository, but it might be that someone will notice an error and correct me.
  2. Mbed TLS can't find locally installed certificates. Can we do anything with it?
  3. Self-signed certificate should be attached to a program manually. Is there any API for this?

Fail to precompile on windows 7

MbedTLS cannot precompile at first Julia run on Atom IDE (clean install with new computer)

PowerShell version < 3 encountered. Running without wrapper (interrupts won't work).
INFO: Precompiling module MbedTLS.
ERROR: LoadError: could not open file C:\Users\kimyonghee\.julia\v0.5\MbedTLS\src\..\deps\deps.jl
 in include_from_node1(::String) at .\loading.jl:488 (repeats 2 times)
 in macro expansion; at .\none:2 [inlined]
 in anonymous at .\<missing>:?
 in eval(::Module, ::Any) at .\boot.jl:234
 in process_options(::Base.JLOptions) at .\client.jl:242
 in _start() at .\client.jl:321
while loading C:\Users\kimyonghee\.julia\v0.5\MbedTLS\src\MbedTLS.jl, in expression starting on line 40
......

Creating empty deps.jl file on ..\deps\ folder solves this problem and I could've run Julia on Atom IDE.

here is versioninfo()

Julia Version 0.5.2
Commit f4c6c9d (2017-05-06 16:34 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i5-6600 CPU @ 3.30GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.7.1 (ORCJIT, broadwell)

Error using `parse_key!` on key string

I am getting an error using parse_key! on a string containing a key.

ERROR: MethodError: no method matching unsafe_convert(::Type{Ptr{Void}}, ::String)
...

The existing function is converting the key input to a String, but it looks like the C function needs an array of UInt8 which I've shown in my example below.

I am using Julia 0.5 and the latest version of MbedTLS.jl

Example

key = """\
-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDyyk0DCzjsQimZ
/KoOIhJQaKugt8tNaoYb4fxbgp5hIRZES1hC5dl63+hk3/1YWRmDwIzq45zk1o0T
fPPS0qFM81o9fuSeVuCeqAWKKz8DLAfAe4iif9oxtvat9svS0TCpa6l3qsZk0Q+R
0r55iBh6pSHeqzWzIef/JKOcx5Bh+ycuqgospY8RVNGqNgz0ZVCY+qodrlWwSVBv
Pd4Eyn8KQwoU5zvrM6NqYHzVWZ2GpGaSIyhsMhC8jQklJHoVOESUb21ALAZ3KwF0
rHuKVo346wbYuqPiAb6dj/7q22Qzye4IO/5fSVYTiUM7JTm+ooLuNPpnKnpg6fo7
B0spILrPAgMBAAECggEBANHZQykfWQrzwMtk1IM0tcmkPrvCQElgihutfxaFVmkz
VPCgguAHlKscvtv5shrboC79jY80PpaYTwWKGaCeB2bga539gJLPGoRnS6p56JPQ
Sb73x0hU433W223Pg6pqvvmgobBZ/fKDtEZg9dtLY4UWF6lDKD31T3V68KOA5e2Y
nNhg4cv6ETNvqpfoXdtIl+Gzg0LMHdyz+pSCrx2mtf8esEJ3wiDYoRUdrq5WRP9S
Vihui0V4JY0WJlPxPFmOZ8JGLGOWZxtKozXmWkcHq1o0r2eFmxIdwF+ZNDosHOID
RV097BUUMcnP6zRdUhk489aStTdHl5aFOcD+fS6oD6kCgYEA/u9PoGs8TCZmwYD5
EG40N2F6BtCWu+7W+bGUwEUAtBxp3KldajTTGARpTClsOvTYts/jshSsnB+e037X
VxAac0ufcKm2YnU0SADoocoSxwZzQoDn/GtalPFOH8bV6SoPZ8y7YEIpPmP9ztk9
z5vCnBw30X9uAZ5zfmWs8tAcwsUCgYEA883/24uDg34mMGnMNNwaY001D4CrjGSG
RJte9He6RAWhdyKIRC95kZGCxZ3WCnv2BsMnMveLxNzMtvCBxKNnd+Wr1UwgNAhR
tMpRTBSYtmlLrFXPy5Q9/FU6yBJ2TCrAQNJRMuoIVtuGK+B3eNufNgZDFaJ5H+UH
IS2jRyoV0IMCgYBpeMTuz67wqmqU4DErNQzxZKjBrQbP1e6m+2tZaLLz0VWS75cw
W46CP0D5O6IFeks2xyejA56uMP7a7X1WDdmDnePnDq/gaDErIQUd+qZuJSMGfqJ7
8kZVnMf/qZnSj440GaXkGztJDsFxFLvX6s9HGv2U9S2kCdQqlRJKmwNrKQKBgDim
WRkuZbScD0uYibaOniMMwZOEllfc08YFRB8R4toDZO1FvNv7HAhTA0vfzOhKvXP8
zJLvKi7oDzlC0SRbw6L8Xt0E/0aX2ERl7lX7QzC/brHwjoQDQhPryejLQWmZVWq6
c9ucvatQ/vAbDCetAGWRNu1D/1kF4o43CIV0pfT5AoGBAOcvh0Pl7r0fCECwZq3m
tT9TnkJW6OEE0jeBcUUGgBbICqD/3kfwx5cIQ30OWCU7TQQZY47xZq/APJFHLbo+
7LdqZxqYZ908PLboTFAd0BmLe26nuOzOiaiGTOmjejZ5StmcbHBjVE2n60xLO2C2
g88/oYhs3pHEXv0doTlECvrm
-----END PRIVATE KEY-----"""

Not Working

This doesn't work:

import MbedTLS
ctx = MbedTLS.PKContext()
MbedTLS.parse_key!(ctx, key)

with the error:

ERROR: MethodError: no method matching unsafe_convert(::Type{Ptr{Void}}, ::String)
Closest candidates are:
  unsafe_convert(::Type{Ptr{UInt8}}, ::String) at pointer.jl:27
  unsafe_convert(::Type{Ptr{Int8}}, ::String) at pointer.jl:28
  unsafe_convert{T}(::Type{Ptr{Void}}, ::Base.RefValue{T}) at refpointer.jl:49
  ...
 in macro expansion at /Users/josh/.julia/v0.5/MbedTLS/src/error.jl:3 [inlined]
 in parse_key!(::MbedTLS.PKContext, ::Array{UInt8,1}, ::Nullable{Union{}}) at /Users/josh/.julia/v0.5/MbedTLS/src/pk.jl:46
 in parse_key!(::MbedTLS.PKContext, ::Array{UInt8,1}) at /Users/josh/.julia/v0.5/MbedTLS/src/pk.jl:38

Working

This does work if I make these changes in pk.jl:

function parse_key!(ctx::PKContext, key, maybe_pw::Nullable = Nullable())
    key_bs = convert(Vector{UInt8}, key)  # was String(key)
    if isnull(maybe_pw)
        pw = C_NULL
        pw_size = 0
    else
        pw = convert(Vector{UInt8}, get(maybe_pw))  # was String(get(maybe_pw))
        pw_size = sizeof(pw)  # Might be off-by-one
    end
    @err_check ccall((:mbedtls_pk_parse_key, MBED_TLS), Cint,
        (Ptr{Void}, Ptr{Void}, Csize_t, Ptr{Void}, Csize_t),
        ctx.data, key_bs, sizeof(key_bs)+1, pw, pw_size)
end

Error with ECB cipher

Not urgent, but recording this issue in case it is a symptom of a bigger issue:

using MbedTLS

msg         = "Testing ECB encryption"
secret_key  = rand(UInt8, 32)
cipher_text = encrypt(MbedTLS.CIPHER_AES_256_ECB, secret_key, msg)

The output I get is:

ERROR: MbedTLS error code -25216: CIPHER - Decryption of block requires a full block
 [inlined code] from /home/jock/.julia/v0.4/MbedTLS/src/error.jl:4
 in crypt! at /home/jock/.julia/v0.4/MbedTLS/src/cipher.jl:3
 in crypt at /home/jock/.julia/v0.4/MbedTLS/src/cipher.jl:290
 in encrypt at /home/jock/.julia/v0.4/MbedTLS/src/cipher.jl:316

InexactError(:check_top_bit, Int64, -149) in unsafe_write at ssl.jl:169

I haven't tried to debug this yet. Any ideas?

Version 0.7.0-DEV.3090 (2017-12-18 19:26 UTC)
Commit 5abe9b1382* (10 days old master)
x86_64-apple-darwin14.5.0

InexactError(:check_top_bit, Int64, -149)39-element Array{StackFrame,1}:
 throw_inexacterror(::Symbol, ::Type{Int64}, ::Int64) at int.jl:34
 check_top_bit at int.jl:428 [inlined]
 convert at int.jl:487 [inlined]
 unsafe_write at io.jl:497 [inlined]
 macro expansion at pointer.jl:169 [inlined]
 write(::TCPSocket, ::Array{UInt8,1}) at io.jl:520
 f_send(::Ptr{Void}, ::Ptr{UInt8}, ::UInt64) at ssl.jl:97
 unsafe_write at ssl.jl:169 [inlined]
 unsafe_write(::Connection{MbedTLS.SSLContext}, ::Ptr{UInt8}, ::UInt64) at ConnectionPool.jl:70
 unsafe_write(::HTTPStream, ::Ptr{UInt8}, ::UInt64) at HTTPStreams.jl:25
 unsafe_write at io.jl:497 [inlined]
 write(::HTTPStream, ::Array{UInt8,1}) at io.jl:520

LoadError: Force rebuild not allowed for binaries

I'm on Windows 7, and building MbedTLS fails with the following error:

===============================[ ERROR: MbedTLS ]===============================

LoadError: Force rebuild not allowed for binaries. Use a different download location instead.
while loading C:\Users\cbinz\.julia\v0.4\MbedTLS\deps\build.jl, in expression starting on line 74

================================================================================

================================[ BUILD ERRORS ]================================

WARNING: MbedTLS had build errors.

 - packages with build errors remain installed in C:\Users\cbinz\.julia\v0.4
 - build the package(s) and all dependencies with `Pkg.build("MbedTLS")`
 - build a single package by running its `deps/build.jl` script

================================================================================
julia> versioninfo()
Julia Version 0.4.6
Commit 2e358ce (2016-06-19 17:16 UTC)
Platform Info:
  System: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Xeon(R) CPU E5-1650 0 @ 3.20GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Sandybridge)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.3

Deprecation warnings

Fix for pointer_to_array deprecation.

diff --git a/src/ctr_drbg.jl b/src/ctr_drbg.jl
index 14b46a8..e279e11 100644
--- a/src/ctr_drbg.jl
+++ b/src/ctr_drbg.jl
@@ -20,7 +20,7 @@ end

 function f_rng(c_ctx, c_buf, sz)
     jl_ctx = unsafe_pointer_to_objref(c_ctx)
-    jl_buf = pointer_to_array(c_buf, sz, false)
+    jl_buf = unsafe_wrap(Array, c_buf, sz, false)
     rand!(jl_ctx, jl_buf)
     MBED_SUCCESS
 end
diff --git a/src/ssl.jl b/src/ssl.jl
index 0ae7be6..08dea7d 100644
--- a/src/ssl.jl
+++ b/src/ssl.jl
@@ -92,13 +92,13 @@ end

 function f_send(c_ctx, c_msg, sz)
     jl_ctx = unsafe_pointer_to_objref(c_ctx)
-    jl_msg = pointer_to_array(c_msg, sz, false)
+    jl_msg = unsafe_wrap(Array, c_msg, sz, false)
     return Cint(write(jl_ctx, jl_msg))
 end

 function f_recv(c_ctx, c_msg, sz)
     jl_ctx = unsafe_pointer_to_objref(c_ctx)
-    jl_msg = pointer_to_array(c_msg, sz, false)
+    jl_msg = unsafe_wrap(Array, c_msg, sz, false)
     n = readbytes!(jl_ctx, jl_msg, sz)
     return Cint(n)
 end

build: Fails with "cannot find 7z"

When running Pkg.update(); Pkg.add("MbedTLS"); in Julia 0.5.0-dev+2013, the build step fails with an error while trying to run 7z.

Here is the print-out:

julia> Pkg.update(); Pkg.add("MbedTLS")
INFO: Updating METADATA...
[...]
INFO: Installing MbedTLS v0.2.0
INFO: Building MbedTLS

PowerShell[.exe] [-PSConsoleFile <file> | -Version <version>]
    [-NoLogo] [-NoExit] [-Sta] [-Mta] [-NoProfile] [-NonInteractive]
    [-InputFormat {Text | XML}] [-OutputFormat {Text | XML}]
    [-WindowStyle <style>] [-EncodedCommand <Base64EncodedCommand>]
    [-File <filePath> <args>] [-ExecutionPolicy <ExecutionPolicy>]
    [-Command { - | <script-block> [-args <arg-array>]
                  | <string> [<CommandParameters>] } ]

PowerShell[.exe] -Help | -? | /?

-PSConsoleFile
    Loads the specified Windows PowerShell console file. To create a console
    file, use Export-Console in Windows PowerShell.

-Version
    Starts the specified version of Windows PowerShell.
    Enter a version number with the parameter, such as "-version 2.0".

-NoLogo
    Hides the copyright banner at startup.

-NoExit
    Does not exit after running startup commands.

-Sta
    Starts the shell using a single-threaded apartment.
    Single-threaded apartment (STA) is the default.

-Mta
    Start the shell using a multithreaded apartment.

-NoProfile
    Does not load the Windows PowerShell profile.

-NonInteractive
    Does not present an interactive prompt to the user.

-InputFormat
    Describes the format of data sent to Windows PowerShell. Valid values are
    "Text" (text strings) or "XML" (serialized CLIXML format).

-OutputFormat
    Determines how output from Windows PowerShell is formatted. Valid values
    are "Text" (text strings) or "XML" (serialized CLIXML format).

-WindowStyle
    Sets the window style to Normal, Minimized, Maximized or Hidden.

-EncodedCommand
    Accepts a base-64-encoded string version of a command. Use this parameter
    to submit commands to Windows PowerShell that require complex quotation
    marks or curly braces.

-File
    Runs the specified script in the local scope ("dot-sourced"), so that the
    functions and variables that the script creates are available in the
    current session. Enter the script file path and any parameters.
    File must be the last parameter in the command, because all characters
    typed after the File parameter name are interpreted
    as the script file path followed by the script parameters.

-ExecutionPolicy
    Sets the default execution policy for the current session and saves it
    in the $env:PSExecutionPolicyPreference environment variable.
    This parameter does not change the Windows PowerShell execution policy
    that is set in the registry.

-Command
    Executes the specified commands (and any parameters) as though they were
    typed at the Windows PowerShell command prompt, and then exits, unless
    NoExit is specified. The value of Command can be "-", a string. or a
    script block.

    If the value of Command is "-", the command text is read from standard
    input.

    If the value of Command is a script block, the script block must be enclosed
    in braces ({}). You can specify a script block only when running PowerShell.exe
    in Windows PowerShell. The results of the script block are returned to the
    parent shell as deserialized XML objects, not live objects.

    If the value of Command is a string, Command must be the last parameter
    in the command , because any characters typed after the command are
    interpreted as the command arguments.

    To write a string that runs a Windows PowerShell command, use the format:
        "& {<command>}"
    where the quotation marks indicate a string and the invoke operator (&)
    causes the command to be executed.

-Help, -?, /?
    Shows this message. If you are typing a PowerShell.exe command in Windows
    PowerShell, prepend the command parameters with a hyphen (-), not a forward
    slash (/). You can use either a hyphen or forward slash in Cmd.exe.

EXAMPLES
    PowerShell -PSConsoleFile SqlSnapIn.Psc1
    PowerShell -version 2.0 -NoLogo -InputFormat text -OutputFormat XML
    PowerShell -Command {Get-EventLog -LogName security}
    PowerShell -Command "& {Get-EventLog -LogName security}"

    # To use the -EncodedCommand parameter:
    $command = 'dir "c:\program files" '
    $bytes = [System.Text.Encoding]::Unicode.GetBytes($command)
    $encodedCommand = [Convert]::ToBase64String($bytes)
    powershell.exe -encodedCommand $encodedCommand
INFO: Attempting to Create directory C:\Users\[REDACTED]\.julia\v0.5\MbedTLS\deps\downloads
INFO: Downloading file https://cache.e.ip.saba.us/https://malmaud.github.io/files/mbedtls-2.1.1-r1.zip
INFO: Done downloading file https://cache.e.ip.saba.us/https://malmaud.github.io/files/mbedtls-2.1.1-r1.zip
INFO: Attempting to Create directory C:\Users\[REDACTED]\.julia\v0.5\MbedTLS
INFO: Directory C:\Users\[REDACTED]\.julia\v0.5\MbedTLS already created
===================================================[ ERROR: MbedTLS ]===================================================


LoadError: could not spawn `7z x 'C:\Users\[REDACTED]\.julia\v0.5\MbedTLS\deps\downloads\mbedtls-2.1.1-r1.zip' -y '-oC:\Users\[REDACTED]\.julia\v0.5\MbedTLS\deps'`: no such file or directory (ENOENT)
while loading C:\Users\[REDACTED]\.julia\v0.5\MbedTLS\deps\build.jl, in expression starting on line 68

========================================================================================================================


====================================================[ BUILD ERRORS ]====================================================


WARNING: MbedTLS had build errors.

 - packages with build errors remain installed in C:\Users\[REDACTED]\.julia\v0.5
 - build the package(s) and all dependencies with `Pkg.build("MbedTLS")`
 - build a single package by running its `deps/build.jl` script

========================================================================================================================

INFO: No packages to install, update or remove
INFO: Package database updated

julia>

Build error with Julia 0.4.6 os OSX 10.11.6

Trying to build MbedTLS from the Julia REPL I obtain the following error:

julia> Pkg.build("MbedTLS")
INFO: Building Homebrew
Already up-to-date.
INFO: Building MbedTLS
===============================[ ERROR: MbedTLS ]===============================

LoadError: Provider BinDeps.PackageManager failed to satisfy dependency libmbedtls
while loading /Users/mzumaya/.julia/v0.4/MbedTLS/deps/build.jl, in expression starting on line 74

================================================================================

=============================================[ BUILD ERRORS ]==============================================

WARNING: MbedTLS had build errors.

 - packages with build errors remain installed in /Users/mzumaya/.julia/v0.4
 - build the package(s) and all dependencies with `Pkg.build("MbedTLS")`
 - build a single package by running its `deps/build.jl` script

===========================================================================================================

apparently the problem is with libmbedtls, but I haven't found any leads to solve the problem, I've already deleted the Homebrew folder in .julia and reinstalled it with Pkg.add("Homebrew") without any success, despite there's a file called libmbedtls.a in /Users/mzumaya/.julia/v0.4/Homebrew/deps/usr/Cellar/mbedtls/2.3.0_1/lib

Failing request for https example from HttpServer

Hi there,

Not sure if this is an issue with MbedTLS.jl or another package, but here it is:

I get HttpServer.jl/examples/https.jl running in one terminal.
In another terminal:

using Requests
get("https://0.0.0.0:8002")

The error is get in the client terminal is:
ERROR: MbedTLS error code -9984: X509 - Certificate verification failed, e.g. CRL, CA or signature failed.

Any ideas?
I am using the latest release of each package, i.e., I'm not using the latest commit on master.

Cheers,
Jock

No sphinx-doc.rb file while building.

On julia 0.4.6, OSX ElCapitan I get this error while trying to build MbedTLS.

julia> Pkg.build("MbedTLS")
INFO: Building Homebrew
Already up-to-date.
INFO: Building MbedTLS

====[ ERROR: MbedTLS]====

LoadError: SystemError: opening file /Users/florin/.julia/v0.4/Homebrew/deps/usr/Library/Formula/sphinx-doc.rb: No such file or directory
while loading /Users/florin/.julia/v0.4/MbedTLS/deps/build.jl, in expression starting on line 74

====[ BUILD ERRORS ]====

WARNING: MbedTLS had build errors.

 - packages with build errors remain installed in /Users/florin/.julia/v0.4
 - build the package(s) and all dependencies with `Pkg.build("MbedTLS")`
 - build a single package by running its `deps/build.jl` script

invalid type for argument rng in method definition for gen_key

Trying to use this on a bleeding edge version of Julia fails with:

julia> using MbedTLS                                                                                                       [6/400]
[ Info: Precompiling module MbedTLS
WARNING: importing deprecated binding Base.AbstractRNG into MbedTLS.
ERROR: LoadError: LoadError: ArgumentError: invalid type for argument rng in method definition for gen_key at /home/sabae/.julia/v0.7/MbedTLS/src/rsa.jl:97
Stacktrace:
 [1] top-level scope
 [2] include at ./boot.jl:292 [inlined]
 [3] include_relative(::Module, ::String) at ./loading.jl:521
 [4] include at ./sysimg.jl:26 [inlined]
 [5] include(::String) at /home/sabae/.julia/v0.7/MbedTLS/src/MbedTLS.jl:2
 [6] top-level scope
 [7] include at ./boot.jl:292 [inlined]
 [8] include_relative(::Module, ::String) at ./loading.jl:521
 [9] include(::Module, ::String) at ./sysimg.jl:26
 [10] top-level scope
 [11] eval at ./boot.jl:295 [inlined]
 [12] top-level scope at ./<missing>:2
in expression starting at /home/sabae/.julia/v0.7/MbedTLS/src/rsa.jl:96
in expression starting at /home/sabae/.julia/v0.7/MbedTLS/src/MbedTLS.jl:56

I'm guessing that something broke 0.7 compat recently? @quinnj

deps.jl requires root

On adding the package on my system, deps.jl contained the following line:

@checked_lib MBED_TLS "/usr/lib64/libmbedtls.so.9"

This file does not exist on my system (likely because I denied the requested root access during build).

I found libmbedtls.so.10 (and it's symlink libmbedtls.so) in MbedTLS/deps/src/mbedtls-2.1.1/library so I changed the line in deps.jl to the following (not sure it's that 100% correct, but the package is doing what I need it to do for now):

@checked_lib MBED_TLS "/home/user/.julia/v0.4/MbedTLS/deps/src/mbedtls-2.1.1/library/libmbedtls.so"

Should root access really be required? Can the default build be adjusted to look for the file in the package directory rather than /usr/lib64?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.