Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AmiSSL support #3677

Closed
wants to merge 14 commits into from
@@ -1031,6 +1031,10 @@ AC_DEFUN([CURL_CHECK_FUNC_RECV], [
#endif
#endif
#else
#ifdef HAVE_PROTO_BSDSOCKET_H
#include <proto/bsdsocket.h>
struct Library *SocketBase = NULL;
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
@@ -1076,6 +1080,10 @@ AC_DEFUN([CURL_CHECK_FUNC_RECV], [
#endif
#define RECVCALLCONV PASCAL
#else
#ifdef HAVE_PROTO_BSDSOCKET_H
#include <proto/bsdsocket.h>
struct Library *SocketBase = NULL;
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
@@ -1084,8 +1092,10 @@ AC_DEFUN([CURL_CHECK_FUNC_RECV], [
#endif
#define RECVCALLCONV
#endif
#ifndef HAVE_PROTO_BSDSOCKET_H
extern $recv_retv RECVCALLCONV
recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
#endif
]],[[
$recv_arg1 s=0;
$recv_arg2 buf=0;
@@ -1165,6 +1175,10 @@ AC_DEFUN([CURL_CHECK_FUNC_SEND], [
#endif
#endif
#else
#ifdef HAVE_PROTO_BSDSOCKET_H
#include <proto/bsdsocket.h>
struct Library *SocketBase = NULL;
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
@@ -1210,6 +1224,10 @@ AC_DEFUN([CURL_CHECK_FUNC_SEND], [
#endif
#define SENDCALLCONV PASCAL
#else
#ifdef HAVE_PROTO_BSDSOCKET_H
#include <proto/bsdsocket.h>
struct Library *SocketBase = NULL;
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
@@ -1218,8 +1236,10 @@ AC_DEFUN([CURL_CHECK_FUNC_SEND], [
#endif
#define SENDCALLCONV
#endif
#ifndef HAVE_PROTO_BSDSOCKET_H
extern $send_retv SENDCALLCONV
send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
#endif
]],[[
$send_arg1 s=0;
$send_arg3 len=0;
@@ -1321,6 +1341,10 @@ AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
#endif
#endif
#else
#ifdef HAVE_PROTO_BSDSOCKET_H
#include <proto/bsdsocket.h>
struct Library *SocketBase = NULL;
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
@@ -1714,6 +1738,7 @@ dnl using current libraries or if another one is required.

AC_DEFUN([CURL_CHECK_LIBS_CONNECT], [
AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
AC_MSG_CHECKING([for connect in libraries])
tst_connect_save_LIBS="$LIBS"
tst_connect_need_LIBS="unknown"
@@ -1723,7 +1748,8 @@ AC_DEFUN([CURL_CHECK_LIBS_CONNECT], [
AC_LINK_IFELSE([
AC_LANG_PROGRAM([[
$curl_includes_winsock2
#ifndef HAVE_WINDOWS_H
$curl_includes_bsdsocket
#if !defined(HAVE_WINDOWS_H) && !defined(HAVE_PROTO_BSDSOCKET_H)
int connect(int, void*, int);
#endif
]],[[
@@ -1854,6 +1880,11 @@ AC_DEFUN([CURL_CHECK_FUNC_SELECT], [
#endif
#endif
#ifndef HAVE_WINDOWS_H
#ifdef HAVE_PROTO_BSDSOCKET_H
#include <proto/bsdsocket.h>
struct Library *SocketBase = NULL;
#define select(a,b,c,d,e) WaitSelect(a,b,c,d,e,0)
#endif
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
@@ -1912,6 +1943,11 @@ AC_DEFUN([CURL_CHECK_FUNC_SELECT], [
#endif
#endif
#ifndef HAVE_WINDOWS_H
#ifdef HAVE_PROTO_BSDSOCKET_H
#include <proto/bsdsocket.h>
struct Library *SocketBase = NULL;
#define select(a,b,c,d,e) WaitSelect(a,b,c,d,e,0)
#endif
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
@@ -1926,12 +1962,14 @@ AC_DEFUN([CURL_CHECK_FUNC_SELECT], [
long tv_usec;
};
#endif
#ifndef HAVE_PROTO_BSDSOCKET_H
extern $sel_retv SELECTCALLCONV
select($sel_arg1,
$sel_arg234,
$sel_arg234,
$sel_arg234,
$sel_arg5);
#endif
]],[[
$sel_arg1 nfds=0;
$sel_arg234 rfds=0;
@@ -155,7 +155,7 @@ AC_SUBST(PKGADD_VENDOR)

dnl
dnl initialize all the info variables
curl_ssl_msg="no (--with-{ssl,gnutls,nss,polarssl,mbedtls,cyassl,schannel,secure-transport,mesalink} )"
curl_ssl_msg="no (--with-{ssl,gnutls,nss,polarssl,mbedtls,cyassl,schannel,secure-transport,mesalink,amissl} )"
curl_ssh_msg="no (--with-libssh2)"
curl_zlib_msg="no (--with-zlib)"
curl_brotli_msg="no (--with-brotli)"
@@ -365,6 +365,18 @@ CURL_CHECK_WIN32_LARGEFILE
CURL_MAC_CFLAGS
CURL_SUPPORTS_BUILTIN_AVAILABLE


dnl Check for Amiga bsdsocket.library headers
AC_CHECK_HEADERS([proto/bsdsocket.h],
[
HAVE_PROTO_BSDSOCKET_H=1
AC_DEFINE(HAVE_PROTO_BSDSOCKET_H, 1, [if Amiga bsdsocket.library is in use])
AC_SUBST(HAVE_PROTO_BSDSOCKET_H, [1])],
[],
[]
)

This comment has been minimized.

Copy link
@bagder

bagder Mar 13, 2019

Member

And this header check can't be put among all the other headers that are checked?

This comment has been minimized.

Copy link
@chris-y

chris-y Mar 13, 2019

Author Contributor

I put it there as it needs to be resolved before any of the socket functions are checked, due to required added headers like the winsock check above it.
There's a case for moving it down to the gethostbyname section and making it part of the bsdsocket.library check there (I can't see any other socket lib function checks above this point). That would also confirm that functions from the library are working as expected which would be a useful additional test before it gets enabled.

This comment has been minimized.

Copy link
@chris-y

chris-y Mar 14, 2019

Author Contributor

I've now moved this to be part of the "gethostbyname is in bsdsocket.library" check.



dnl ************************************************************
dnl switch off particular protocols
dnl
@@ -837,6 +849,27 @@ then
])
fi

if test "$HAVE_GETHOSTBYNAME" != "1"
then
dnl This is for AmigaOS with bsdsocket.library - needs testing before -lnet
AC_MSG_CHECKING([for gethostbyname for AmigaOS bsdsocket.library])
AC_LINK_IFELSE([
AC_LANG_PROGRAM([[
#ifdef HAVE_PROTO_BSDSOCKET_H
#include <proto/bsdsocket.h>
struct Library *SocketBase = NULL;
#endif
]],[[
gethostbyname("www.dummysite.com");
]])
],[
AC_MSG_RESULT([yes])
HAVE_GETHOSTBYNAME="1"
],[
AC_MSG_RESULT([no])
])
fi

if test "$HAVE_GETHOSTBYNAME" != "1"
then
dnl gethostbyname in the network lib - for Haiku OS
@@ -1539,6 +1572,35 @@ else
AC_MSG_RESULT(no)
fi

OPT_AMISSL=no
AC_ARG_WITH(amissl,dnl
AC_HELP_STRING([--with-amissl],[enable Amiga native SSL/TLS (AmiSSL)])
AC_HELP_STRING([--without-amissl], [disable Amiga native SSL/TLS (AmiSSL)]),
OPT_AMISSL=$withval)

AC_MSG_CHECKING([whether to enable Amiga native SSL/TLS (AmiSSL)])
if test "$HAVE_PROTO_BSDSOCKET_H" == "1"; then
if test -z "$ssl_backends" -o "x$OPT_AMISSL" != xno; then
ssl_msg=
if test "x$OPT_AMISSL" != "xno"; then
AC_MSG_RESULT(yes)
ssl_msg="AmiSSL"
test amissl != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes
AMISSL_ENABLED=1
LIBS="-lamisslauto $LIBS"
AC_DEFINE(USE_AMISSL, 1, [if AmiSSL is in use])
AC_DEFINE(USE_OPENSSL, 1, [if OpenSSL is in use])
else
AC_MSG_RESULT(no)
fi
test -z "$ssl_msg" || ssl_backends="${ssl_backends:+$ssl_backends, }$ssl_msg"
else
AC_MSG_RESULT(no)
fi
else
AC_MSG_RESULT(no)
fi

dnl **********************************************************************
dnl Check for the presence of SSL libraries and headers
dnl **********************************************************************
@@ -2638,10 +2700,10 @@ if test -z "$ssl_backends" -o "x$OPT_NSS" != xno; then
test -z "$ssl_msg" || ssl_backends="${ssl_backends:+$ssl_backends, }$ssl_msg"
fi

case "x$OPENSSL_ENABLED$GNUTLS_ENABLED$NSS_ENABLED$POLARSSL_ENABLED$MBEDTLS_ENABLED$CYASSL_ENABLED$WINSSL_ENABLED$SECURETRANSPORT_ENABLED$MESALINK_ENABLED" in
case "x$OPENSSL_ENABLED$GNUTLS_ENABLED$NSS_ENABLED$POLARSSL_ENABLED$MBEDTLS_ENABLED$CYASSL_ENABLED$WINSSL_ENABLED$SECURETRANSPORT_ENABLED$MESALINK_ENABLED$AMISSL_ENABLED" in
x)
AC_MSG_WARN([SSL disabled, you will not be able to use HTTPS, FTPS, NTLM and more.])
AC_MSG_WARN([Use --with-ssl, --with-gnutls, --with-polarssl, --with-cyassl, --with-nss, --with-schannel, --with-secure-transport, or --with-mesalink to address this.])
AC_MSG_WARN([Use --with-ssl, --with-gnutls, --with-polarssl, --with-cyassl, --with-nss, --with-schannel, --with-secure-transport, --with-mesalink or --with-amissl to address this.])
;;
x1)
# one SSL backend is enabled
@@ -3522,6 +3584,7 @@ dnl default includes
]
)


dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
CURL_CHECK_VARIADIC_MACROS
@@ -22,12 +22,12 @@

#include "curl_setup.h"

#if defined(__AMIGA__) && !defined(__ixemul__)
#ifdef __AMIGA__
#include "amigaos.h"

#if defined(HAVE_PROTO_BSDSOCKET_H) && !defined(USE_AMISSL)
#include <amitcp/socketbasetags.h>

#include "amigaos.h"

struct Library *SocketBase = NULL;
extern int errno, h_errno;

@@ -74,4 +74,13 @@ bool Curl_amiga_init()
ADD2EXIT(Curl_amiga_cleanup, -50);
#endif

#endif /* __AMIGA__ && ! __ixemul__ */
#endif /* HAVE_PROTO_BSDSOCKET_H */

#ifdef USE_AMISSL
void Curl_amiga_X509_free(X509 *a)
{
X509_free(a);
}
#endif /* USE_AMISSL */
#endif /* __AMIGA__ */

@@ -23,7 +23,7 @@
***************************************************************************/
#include "curl_setup.h"

#if defined(__AMIGA__) && !defined(__ixemul__)
#if defined(__AMIGA__) && defined(HAVE_BSDSOCKET_H) && !defined(USE_AMISSL)

bool Curl_amiga_init();
void Curl_amiga_cleanup();
@@ -35,4 +35,10 @@ void Curl_amiga_cleanup();

#endif

#ifdef USE_AMISSL
#include <openssl/x509v3.h>
void Curl_amiga_X509_free(X509 *a);
#endif /* USE_AMISSL */

#endif /* HEADER_CURL_AMIGAOS_H */

@@ -310,11 +310,12 @@
#endif

#ifdef __AMIGA__
# ifndef __ixemul__
# include <exec/types.h>
# include <exec/execbase.h>
# include <proto/exec.h>
# include <proto/dos.h>
# include <exec/types.h>
# include <exec/execbase.h>
# include <proto/exec.h>
# include <proto/dos.h>
# ifdef HAVE_PROTO_BSDSOCKET_H
# include <proto/bsdsocket.h> /* ensure we're using bsdsocket.library functions */
# define select(a,b,c,d,e) WaitSelect(a,b,c,d,e,0)
# endif
#endif
@@ -83,7 +83,7 @@ static void MD5_Final(unsigned char digest[16], MD5_CTX * ctx)
gcry_md_close(*ctx);
}

#elif defined(USE_OPENSSL)
#elif defined(USE_OPENSSL) && !defined(USE_AMISSL)
/* When OpenSSL is available we use the MD5-function from OpenSSL */
#include <openssl/md5.h>
#include "curl_memory.h"
@@ -65,6 +65,10 @@
#include <openssl/buffer.h>
#include <openssl/pkcs12.h>

#ifdef USE_AMISSL
#include "amigaos.h"
#endif

#if (OPENSSL_VERSION_NUMBER >= 0x0090808fL) && !defined(OPENSSL_NO_OCSP)
#include <openssl/ocsp.h>
#endif
@@ -820,8 +824,11 @@ int cert_stuff(struct connectdata *conn,
fail:
EVP_PKEY_free(pri);
X509_free(x509);
#ifdef USE_AMISSL
sk_X509_pop_free(ca, Curl_amiga_X509_free);
#else
sk_X509_pop_free(ca, X509_free);

#endif
if(!cert_done)
return 0; /* failure! */
break;
@@ -248,7 +248,7 @@ Curl_ssl_connect(struct connectdata *conn, int sockindex)
conn->ssl[sockindex].use = TRUE;
conn->ssl[sockindex].state = ssl_connection_negotiating;

result = Curl_ssl->connect(conn, sockindex);
result = Curl_ssl->connect_blocking(conn, sockindex);

This comment has been minimized.

Copy link
@bagder

bagder Mar 13, 2019

Member

This isn't gcc's fault, this is some silly headers you use that seems to implement some of the socket API functions as macros and thus banning the function names from use everywhere. I'd say that is pretty bad style but I also realize you're not to blame for that...

This comment has been minimized.

Copy link
@chris-y

chris-y Mar 13, 2019

Author Contributor

Yes, it's the bsdsocket inline header. All Amiga 68k libraries are called using macros like that, the macros set the values in the correct registers then jump to the function code. Unfortunately not much I can do about that, it was a design decision taken ~35 years ago!


if(!result)
Curl_pgrsTime(conn->data, TIMER_APPCONNECT); /* SSL is connected */
@@ -557,7 +557,7 @@ void Curl_ssl_close(struct connectdata *conn, int sockindex)

CURLcode Curl_ssl_shutdown(struct connectdata *conn, int sockindex)
{
if(Curl_ssl->shutdown(conn, sockindex))
if(Curl_ssl->shut_down(conn, sockindex))
return CURLE_SSL_SHUTDOWN_FAILED;

conn->ssl[sockindex].use = FALSE; /* get back to ordinary socket usage */
@@ -1114,7 +1114,7 @@ static CURLcode Curl_multissl_connect(struct connectdata *conn, int sockindex)
{
if(multissl_init(NULL))
return CURLE_FAILED_INIT;
return Curl_ssl->connect(conn, sockindex);
return Curl_ssl->connect_blocking(conn, sockindex);
}

static CURLcode Curl_multissl_connect_nonblocking(struct connectdata *conn,
@@ -47,7 +47,7 @@ struct Curl_ssl {

size_t (*version)(char *buffer, size_t size);
int (*check_cxn)(struct connectdata *cxn);
int (*shutdown)(struct connectdata *conn, int sockindex);
int (*shut_down)(struct connectdata *conn, int sockindex);
bool (*data_pending)(const struct connectdata *conn,
int connindex);

@@ -56,7 +56,7 @@ struct Curl_ssl {
size_t length);
bool (*cert_status_request)(void);

CURLcode (*connect)(struct connectdata *conn, int sockindex);
CURLcode (*connect_blocking)(struct connectdata *conn, int sockindex);
CURLcode (*connect_nonblocking)(struct connectdata *conn, int sockindex,
bool *done);
void *(*get_internals)(struct ssl_connect_data *connssl, CURLINFO info);
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.