TLS: shutdown before close (notify_close must be sent)
parent
45a52189e4
commit
b02b8571a0
|
@ -40,8 +40,9 @@ write(c::SSLClient, s::String) = write(c, Vector{UInt8}(s))
|
|||
|
||||
import Base.close
|
||||
function close(client::SSLClient)
|
||||
closed = do_ssl_shutdown(client)
|
||||
@show closed
|
||||
close(client.sock)
|
||||
shutdown(client)
|
||||
free(client)
|
||||
end
|
||||
|
||||
|
|
|
@ -128,3 +128,30 @@ function do_sock_write(client::SSLClient)
|
|||
return -1
|
||||
end
|
||||
end
|
||||
|
||||
function do_ssl_shutdown(client)
|
||||
n = shutdown(client)
|
||||
status = ssl_status(client, n)
|
||||
# Special case, do the shutdown again
|
||||
if n == 0
|
||||
n = shutdown(client)
|
||||
@show status = ssl_status(client, n)
|
||||
end
|
||||
if status in (SSL_WANT_READ, SSL_WANT_WRITE)
|
||||
@info "READING"
|
||||
while true
|
||||
(n, buf) = bio_read(client)
|
||||
println("bio_read: $(n)")
|
||||
if n > 0
|
||||
queue_encrypted_bytes(client, buf)
|
||||
elseif !bio_should_retry(client.wbio)
|
||||
return -1
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
@show ssl_status(client, shutdown(client))
|
||||
# println("End of ssl handshake")
|
||||
return status
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue