Julia OpenSSL wrapper
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.7 KiB

ssl_version(client) =
ccall((:SSL_client_version, libssl), SSL_VERSION, (Ptr{Cvoid}, ), client.ssl)
SSL_handshake(client::SSLClient) =
ccall((:SSL_do_handshake, libssl), Cint, (Ptr{Cvoid},), client.ssl)
SSL_new(ctx::SSLContext) =
ccall((:SSL_new, libssl), Ptr{Cvoid}, (Ptr{Cvoid},), ctx.ptr)
SSL_CTX_new(method::Ptr{SSL_Method}) =
ccall((:SSL_CTX_new, libssl), Ptr{SSL_Context}, (Ptr{SSL_Method},), method)
SSL_accept_state(client::SSLClient) =
ccall((:SSL_set_accept_state, libssl), Ptr{Cvoid}, (Ptr{Cvoid},), client.ssl)
SSL_connect_state(client::SSLClient) =
ccall((:SSL_set_connect_state, libssl), Ptr{Cvoid}, (Ptr{Cvoid},), client.ssl)
ssl_init_finished(client::SSLClient) =
ccall((:SSL_is_init_finished, libssl), Bool, (Ptr{Cvoid},), client.ssl)
accept(client::SSLClient) =
ccall((:SSL_accept, libssl), Cint, (Ptr{Cvoid}, ), client.ssl)
ssl_status(client::SSLClient, n) =
ccall((:SSL_get_error, libssl), SSL_ERRORS, (Ptr{Cvoid}, Cint), client.ssl, n)
ssl_read!(client::SSLClient, buf::Vector{UInt8}) =
ccall((:SSL_read, libssl), Cint, (Ptr{Cvoid}, Ptr{Cvoid}, Cint),
client.ssl, buf, length(buf))
ssl_write(client::SSLClient, buf::Vector{UInt8}) =
ccall((:SSL_write, libssl), Cint, (Ptr{Cvoid}, Ptr{Cvoid}, Cint),
client.ssl, buf, length(buf))
shutdown(client::SSLClient) =
ccall((:SSL_shutdown, libssl), Cint, (Ptr{Cvoid},), client.ssl)
free(client::SSLClient) = ccall((:SSL_free, libssl), Cint, (Ptr{Cvoid},), client.ssl)
const TLSEXT_NAMETYPE_host_name = 0
set_host_name(client::SSLClient, name::String) =
ccall((:SSL_ctrl, libssl), Cint, (Ptr{Cvoid}, Cint, Cint, Cstring),
client.ssl, SSL_CTRL_SET_TLSEXT_HOSTNAME, TLSEXT_NAMETYPE_host_name, name)