From c7a908cc5adede6ca34519059f2e324dc6737ff6 Mon Sep 17 00:00:00 2001 From: Jeffrey Armstrong Date: Fri, 1 May 2020 11:21:05 -0400 Subject: SSL network connections now seem to work, including on windows --- jessl.f90 | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'jessl.f90') diff --git a/jessl.f90 b/jessl.f90 index a27803e..34fb2a2 100644 --- a/jessl.f90 +++ b/jessl.f90 @@ -5,7 +5,7 @@ implicit none interface - subroutine library_init() bind(c, name="SSL_library_init") + subroutine library_init() bind(c, name="OPENSSL_init_ssl") end subroutine library_init subroutine add_ssl_algorithms() bind(c, name="SSLeay_add_ssl_algorithms") @@ -46,7 +46,7 @@ implicit none function ssl_connect(ssl) bind(c, name="SSL_connect") use iso_c_binding - integer(kind=c_int)::connect + integer(kind=c_int)::ssl_connect type(c_ptr), value::ssl end function ssl_connect @@ -80,6 +80,12 @@ implicit none integer(kind=c_int)::get_error end function get_error + function ssl_pending(ssl) bind(c, name="SSL_pending") + use iso_c_binding + type(c_ptr), value::ssl + integer(kind=c_int)::ssl_pending + end function ssl_pending + end interface contains @@ -91,12 +97,13 @@ contains type(c_ptr)::ssl character, dimension(:), intent(inout)::buf integer::ssl_read + integer::bufsize character(kind=c_char), dimension(:), allocatable::cbuf + bufsize = size(buf) + allocate(cbuf(bufsize)) - allocate(cbuf(size(buf))) - - ssl_read = read_c(ssl, cbuf, size(buf)) + ssl_read = read_c(ssl, cbuf, 1) buf = cbuf deallocate(cbuf) @@ -116,8 +123,9 @@ contains allocate(cbuf(size(buf))) cbuf = buf + cbuf(size(buf)) = c_null_char ssl_write = write_c(ssl, cbuf, size(buf)) - + deallocate(cbuf) end function ssl_write -- cgit v1.2.3