Hello, i have been trying to setup an encrypted TCP server connection using MbedTLS and i have been having trouble getting it working.
I keep receiving: MbedTLS error code -31104: SSL - Processing of the ServerHello handshake message failed
whenever the client attempts to do its handshake.
Why would this be occurring?
server
function loopSecure(port, db)
server = Sockets.listen(port)
control_channel = Channel(10)
task = @async begin
while true
if(isready(control_channel))
val = take!(control_channel)
if(val == false)
break
end
end
conn = TCPSocket()
err = -1
while(err != 0)
err = Sockets.accept_nonblock(server,conn)
sleep(0.001)
end
@debug "Accepted " conn err
@async begin
@debug "Secure Connection Start"
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)
MbedTLS.ca_chain!(conf)
MbedTLS.setup!(ctx, conf)
MbedTLS.set_bio!(ctx, conn)
MbedTLS.handshake(ctx)
state = 0
time_start = 0
while true
if(processConnection(conn, db) )
state = 0
else
if(state == 0)
time_start = now()
state = 1
elseif(state == 1)
if(now() - time_start >= Minute(1))
@debug "Connection Timeout." conn
break
end
end
end
sleep(0.1)
end
end
end
close(server)
end
return server, control_channel
end
client
client=Sockets.connect(8081)
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)
MbedTLS.ca_chain!(conf)
MbedTLS.setup!(ctx, conf)
MbedTLS.set_bio!(ctx, client)
MbedTLS.handshake(ctx)
write(client,buffer)
flush(client)
tmp = readavailable(client)