You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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:
functionparse_key!(ctx::PKContext, key, maybe_pw::Nullable=Nullable())
key_bs =convert(Vector{UInt8}, key) # was String(key)ifisnull(maybe_pw)
pw =C_NULL
pw_size =0else
pw =convert(Vector{UInt8}, get(maybe_pw)) # was String(get(maybe_pw))
pw_size =sizeof(pw) # Might be off-by-oneend@err_checkccall((: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
The text was updated successfully, but these errors were encountered:
I am getting an error using
parse_key!
on a string containing a key.The existing function is converting the
key
input to aString
, but it looks like the C function needs an array ofUInt8
which I've shown in my example below.I am using Julia 0.5 and the latest version of MbedTLS.jl
Example
Not Working
This doesn't work:
with the error:
Working
This does work if I make these changes in
pk.jl
:The text was updated successfully, but these errors were encountered: