JuliaLang / MbedTLS.jl

Wrapper around mbedtls
Other
41 stars 50 forks source link

MethodError on findfirst instead of "Certificate verification failed" #274

Closed nsslh closed 11 months ago

nsslh commented 12 months ago

There's a regression in 1.1.8. Previously, peer certificate validation errors would produce an exception with message "Certificate verification failed".

Since 8c73ac4da, the exception is:

  MethodError: no method matching findfirst(::UInt8, ::Vector{UInt8})

  Closest candidates are:
    findfirst(::AbstractVector{<:Union{Int8, UInt8}}, ::AbstractVector{<:Union{Int8, UInt8}})
     @ Base strings/search.jl:158
    findfirst(::Base.Fix2{<:Union{typeof(==), typeof(isequal)}, <:Union{Int8, UInt8}}, ::Union{Base.CodeUnits{UInt8, String}, Vector{Int8}, Vector{UInt8}, SubArray{Int8, 1, Vector{Int8}, I, true} where I<:Union{Tuple{Vararg{Real}}, Tuple{AbstractUnitRange, Vararg{Any}}}, SubArray{UInt8, 1, Base.CodeUnits{UInt8, String}, I, true} where I<:Union{Tuple{Vararg{Real}}, Tuple{AbstractUnitRange, Vararg{Any}}}, SubArray{UInt8, 1, Vector{UInt8}, I, true} where I<:Union{Tuple{Vararg{Real}}, Tuple{AbstractUnitRange, Vararg{Any}}}})
     @ Base strings/search.jl:32
    findfirst(::typeof(iszero), ::Union{Base.CodeUnits{UInt8, String}, Vector{Int8}, Vector{UInt8}, SubArray{Int8, 1, Vector{Int8}, I, true} where I<:Union{Tuple{Vararg{Real}}, Tuple{AbstractUnitRange, Vararg{Any}}}, SubArray{UInt8, 1, Base.CodeUnits{UInt8, String}, I, true} where I<:Union{Tuple{Vararg{Real}}, Tuple{AbstractUnitRange, Vararg{Any}}}, SubArray{UInt8, 1, Vector{UInt8}, I, true} where I<:Union{Tuple{Vararg{Real}}, Tuple{AbstractUnitRange, Vararg{Any}}}})
     @ Base strings/search.jl:38
    ...

  Stacktrace:
    [1] strerror(ret::Int32, bufsize::Int64)
      @ MbedTLS ~/.julia/packages/MbedTLS/GKTMC/src/error.jl:25
    [2] strerror(ret::Int32)
      @ MbedTLS ~/.julia/packages/MbedTLS/GKTMC/src/error.jl:21
    [3] mbed_ioerr(ret::Int32)
      @ MbedTLS ~/.julia/packages/MbedTLS/GKTMC/src/error.jl:18
    [4] handshake(ctx::MbedTLS.SSLContext)
      @ MbedTLS ~/.julia/packages/MbedTLS/GKTMC/src/ssl.jl:81
    [5] setup_tls(sock::Sockets.TCPSocket, hostname::String, ssl_options::SSLConfig)
      @ AMQPClient ~/.julia/packages/AMQPClient/1GBMt/src/amqps.jl:70
    [6] connection(; virtualhost::String, host::String, port::Int64, framemax::Int64, heartbeat::Bool, keepalive::Int64, send_queue_size::Int64, auth_params::Dict{String, Any}, channelmax::Int64, connect_timeout::Int64, amqps::SSLConfig)
      @ AMQPClient ~/.julia/packages/AMQPClient/1GBMt/src/protocol.jl:662
    [7] run_rpc_server(; host::String, login::String, password::String, queue_name::String, routes::Dict{String, Function}, env::Dict{String, String}, fire_forget::Bool)
      @ RabbitRpcServer /app/src/RabbitRpcServer.jl:169
...

This is on julia-1.9.3, from the julia:1.9.3-alpine3.18 Docker image:

julia> versioninfo()
Julia Version 1.9.3
Commit bed2cd540a1 (2023-08-24 14:43 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-alpine-linux-musl)
  CPU: 16 × Intel(R) Core(TM) i9-10885H CPU @ 2.40GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, skylake)
  Threads: 1 on 16 virtual cores
Environment:
  JULIA_GPG = 3673DF529D9049477F76B37566E3C7DC03D6E495
  JULIA_VERSION = 1.9.3
  JULIA_PATH = /usr/local/julia
nsslh commented 12 months ago

@vtjnash

Since 8c73ac4, the exception is:

  MethodError: no method matching findfirst(::UInt8, ::Vector{UInt8})
nsslh commented 11 months ago

If you're not happy with my butchery of the test suite, you can just cherry-pick nsslh/MbedTLS.jl@1a0fe48.