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

Compile problems with gcc #15

Open
anchor76 opened this issue Mar 18, 2017 · 56 comments
Open

Compile problems with gcc #15

anchor76 opened this issue Mar 18, 2017 · 56 comments
Labels

Comments

@anchor76
Copy link

anchor76 commented Mar 18, 2017

hello,

i trying to compile libCurl with AmiSSL under cygwin. (m68k target)
i use cahirwpz's amigaos-cross-toolchain. i get the following errors:

In file included from /home/anchor/amissl/include/proto/amissl.h:79,
                 from vtls/openssl.c:42:
/home/anchor/amissl/include/amissl/inline.h: In function `sk_SCT_new':
/home/anchor/amissl/include/amissl/inline.h:123: warning: implicit declaration of function `LP1FP'
/home/anchor/amissl/include/amissl/inline.h:123: parse error before `OPENSSL_STACK'
/home/anchor/amissl/include/amissl/inline.h:123: warning: unused parameter `compare'
/home/anchor/amissl/include/amissl/inline.h:123: warning: control reaches end of non-void function
...

screen shot #1
screen shot #2

can i get some advice? :)

thanks

@Futaura
Copy link
Collaborator

Futaura commented Mar 18, 2017

Seems like you perhaps have an old version of inline/macros.h file? Try backing it up and replacing with https://raw.githubusercontent.com/jens-maus/amissl/master/include/inline/macros.h

@anchor76
Copy link
Author

anchor76 commented Mar 19, 2017

hello,

thanks, it worked. alas, i still getting compile error due to another reason:
(libcurl 7.37.1)

anchor@anchor-PC /cygdrive/c/!/_development/curl_lite/lib
$ make -f makefile.amissl
m68k-amigaos-gcc -DAMISSL -L/home/anchor/amissl/include -L/home/anchor/libz/68k -I/home/anchor/amissl/include -I/home/anchor/libz/68k -I/home/anchor/netinclude -m68020-60 -O2 -msoft-float -noixemul -g -I. -I../include -W -Wall   -c -o vtls/openssl.o vtls/openssl.c
vtls/openssl.c: In function `ossl_seed':
vtls/openssl.c:239: warning: implicit declaration of function `RAND_egd'
vtls/openssl.c: In function `ssl_msg_type':
vtls/openssl.c:1303: `SSL2_VERSION_MAJOR' undeclared (first use in this function)
vtls/openssl.c:1303: (Each undeclared identifier is reported only once
vtls/openssl.c:1303: for each function it appears in.)
vtls/openssl.c:1305: `SSL2_MT_ERROR' undeclared (first use in this function)
vtls/openssl.c:1306: warning: unreachable code at beginning of switch statement
vtls/openssl.c:1309: `SSL2_MT_CLIENT_MASTER_KEY' undeclared (first use in this function)
vtls/openssl.c:1311: `SSL2_MT_CLIENT_FINISHED' undeclared (first use in this function)
vtls/openssl.c:1313: `SSL2_MT_SERVER_HELLO' undeclared (first use in this function)
vtls/openssl.c:1315: `SSL2_MT_SERVER_VERIFY' undeclared (first use in this function)
vtls/openssl.c:1317: `SSL2_MT_SERVER_FINISHED' undeclared (first use in this function)
vtls/openssl.c:1319: `SSL2_MT_REQUEST_CERTIFICATE' undeclared (first use in this function)
vtls/openssl.c:1321: `SSL2_MT_CLIENT_CERTIFICATE' undeclared (first use in this function)
vtls/openssl.c: In function `ssl_tls_trace':
vtls/openssl.c:1381: `SSL2_VERSION_MAJOR' undeclared (first use in this function)
vtls/openssl.c:1373: warning: `ver' might be used uninitialized in this function
vtls/openssl.c: In function `get_ssl_version_txt':
vtls/openssl.c:1472: dereferencing pointer to incomplete type
vtls/openssl.c:1475: warning: unreachable code at beginning of switch statement
vtls/openssl.c: In function `ossl_connect_step1':
vtls/openssl.c:1553: warning: implicit declaration of function `SSLv3_client_method'
vtls/openssl.c:1553: warning: assignment makes pointer from integer without a cast
vtls/openssl.c: In function `X509V3_ext':
vtls/openssl.c:2126: warning: implicit declaration of function `M_ASN1_OCTET_STRING_print'
vtls/openssl.c:2126: dereferencing pointer to incomplete type
vtls/openssl.c: In function `get_cert_chain':
vtls/openssl.c:2281: dereferencing pointer to incomplete type
vtls/openssl.c:2283: dereferencing pointer to incomplete type
vtls/openssl.c:2299: dereferencing pointer to incomplete type
vtls/openssl.c:2309: dereferencing pointer to incomplete type
vtls/openssl.c:2312: dereferencing pointer to incomplete type
vtls/openssl.c:2313: dereferencing pointer to incomplete type
vtls/openssl.c:2316: dereferencing pointer to incomplete type
vtls/openssl.c:2316: dereferencing pointer to incomplete type
vtls/openssl.c:2316: dereferencing pointer to incomplete type
vtls/openssl.c:2317: dereferencing pointer to incomplete type
vtls/openssl.c:2317: dereferencing pointer to incomplete type
vtls/openssl.c:2317: dereferencing pointer to incomplete type
vtls/openssl.c:2318: dereferencing pointer to incomplete type
vtls/openssl.c:2318: dereferencing pointer to incomplete type
vtls/openssl.c:2318: dereferencing pointer to incomplete type
vtls/openssl.c:2319: dereferencing pointer to incomplete type
vtls/openssl.c:2319: dereferencing pointer to incomplete type
vtls/openssl.c:2319: dereferencing pointer to incomplete type
vtls/openssl.c:2320: dereferencing pointer to incomplete type
vtls/openssl.c:2320: dereferencing pointer to incomplete type
vtls/openssl.c:2320: dereferencing pointer to incomplete type
vtls/openssl.c:2321: dereferencing pointer to incomplete type
vtls/openssl.c:2321: dereferencing pointer to incomplete type
vtls/openssl.c:2321: dereferencing pointer to incomplete type
vtls/openssl.c:2322: dereferencing pointer to incomplete type
vtls/openssl.c:2322: dereferencing pointer to incomplete type
vtls/openssl.c:2322: dereferencing pointer to incomplete type
vtls/openssl.c:2323: dereferencing pointer to incomplete type
vtls/openssl.c:2323: dereferencing pointer to incomplete type
vtls/openssl.c:2323: dereferencing pointer to incomplete type
vtls/openssl.c:2326: dereferencing pointer to incomplete type
vtls/openssl.c:2326: dereferencing pointer to incomplete type
vtls/openssl.c:2326: dereferencing pointer to incomplete type
vtls/openssl.c:2327: dereferencing pointer to incomplete type
vtls/openssl.c:2327: dereferencing pointer to incomplete type
vtls/openssl.c:2327: dereferencing pointer to incomplete type
vtls/openssl.c:2328: dereferencing pointer to incomplete type
vtls/openssl.c:2328: dereferencing pointer to incomplete type
vtls/openssl.c:2328: dereferencing pointer to incomplete type
vtls/openssl.c:2329: dereferencing pointer to incomplete type
vtls/openssl.c:2329: dereferencing pointer to incomplete type
vtls/openssl.c:2329: dereferencing pointer to incomplete type
vtls/openssl.c:2330: dereferencing pointer to incomplete type
vtls/openssl.c:2330: dereferencing pointer to incomplete type
vtls/openssl.c:2330: dereferencing pointer to incomplete type
vtls/openssl.c:2333: dereferencing pointer to incomplete type
vtls/openssl.c:2333: dereferencing pointer to incomplete type
vtls/openssl.c:2333: dereferencing pointer to incomplete type
vtls/openssl.c:2334: dereferencing pointer to incomplete type
vtls/openssl.c:2334: dereferencing pointer to incomplete type
vtls/openssl.c:2334: dereferencing pointer to incomplete type
vtls/openssl.c:2335: dereferencing pointer to incomplete type
vtls/openssl.c:2335: dereferencing pointer to incomplete type
vtls/openssl.c:2335: dereferencing pointer to incomplete type
vtls/openssl.c:2336: dereferencing pointer to incomplete type
vtls/openssl.c:2336: dereferencing pointer to incomplete type
vtls/openssl.c:2336: dereferencing pointer to incomplete type
vtls/openssl.c:2312: warning: unreachable code at beginning of switch statement
vtls/openssl.c:2347: dereferencing pointer to incomplete type
vtls/openssl.c:2349: dereferencing pointer to incomplete type
make: *** [<builtin>: vtls/openssl.o] Error 1

if i remove SSL2_xxx usage, and i use only SSL3_xxx, those errors gone, but its also ending with compile error. i still investigating this issue...

@anchor76
Copy link
Author

anchor76 commented Mar 19, 2017

let's see the first error with SSL_SESSION:
"vtls/openssl.c: In function get_ssl_version_txt': vtls/openssl.c:1472: dereferencing pointer to incomplete type"

in openssl's ssl.h:

typedef struct ssl_session_st {
...
} SSL_SESSION; 

in amissl's ssl.h:
typedef struct ssl_session_st SSL_SESSION;

@Futaura
Copy link
Collaborator

Futaura commented Mar 19, 2017

That's a rather old libcurl, from 2014, which would be using the old OpenSSL API - that's the reason for those dereferencing errors, as most structures (including ssl_session_st) have been made private since OpenSSL​ 1.1.0 and need to be accessed via functions instead. The OpenSSL ssl.h you are looking at is an old version - the latest is the same as AmiSSL in this respect. I had to fix many issues in IBrowse like this, but presumably the latest libcurl is already compatible with OpenSSL 1.1.0.

@jens-maus
Copy link
Owner

@anchor76 Oliver ist correct here. Your CURL version is simply too old and doesn't support OpenSSL 1.1.x. You will have to update libcurl to something like 7.50.x or newer which come with support for the newer OpenSSL 1.1.x API which AmiSSLv4 is based on.

@anchor76
Copy link
Author

ok, thanks guys ;)

@anchor76
Copy link
Author

anchor76 commented Mar 19, 2017

ok, i managed to compile the latest libCurl with AmiSSL.
now i trying to compile my c++ project with libCurl+AmiSSL, and i get tons of 'undefined reference' errors in libCurl/openssl.c:

m68k-amigaos-g++ ../shared/start_68k.o ../../obj/google_drive_handler.o ../../obj/dos_handler.o ../../obj/fw_util.o -o "devs/google-drive-handler.68k" -L../../../framework/thirdparty/libcurl/68k -L/home/anchor/amissl/lib/AmigaOS3 -L../../../framework/thirdparty/libz/68k -s -lcurl_amissl -lamisslauto -lz -lnix -lstubs -noixemul -nostartfiles
../../../framework/thirdparty/libcurl/68k/libcurl_amissl.a(openssl.o): In function `Curl_ossl_seed':
/cygdrive/c/!/_development/curl-7.53.1/lib/vtls/openssl.c:246: undefined reference to `RAND_bytes'
../../../framework/thirdparty/libcurl/68k/libcurl_amissl.a(openssl.o): In function `verifyhost':
/cygdrive/c/!/_development/curl-7.53.1/lib/vtls/openssl.c:1213: undefined reference to `X509_NAME_get_index_by_NID'
../../../framework/thirdparty/libcurl/68k/libcurl_amissl.a(openssl.o): In function `verifystatus':
/cygdrive/c/!/_development/curl-7.53.1/lib/vtls/openssl.c:1345: undefined reference to `sk_num'
/cygdrive/c/!/_development/curl-7.53.1/lib/vtls/openssl.c:1346: undefined reference to `sk_value'
/cygdrive/c/!/_development/curl-7.53.1/lib/vtls/openssl.c:1368: undefined reference to `OCSP_resp_count'
../../../framework/thirdparty/libcurl/68k/libcurl_amissl.a(openssl.o): In function `ossl_connect_step1':
/cygdrive/c/!/_development/curl-7.53.1/lib/vtls/openssl.c:1804: undefined reference to `SSL_CTX_ctrl'
/cygdrive/c/!/_development/curl-7.53.1/lib/vtls/openssl.c:2093: undefined reference to `SSL_CTX_get_cert_store'
../../../framework/thirdparty/libcurl/68k/libcurl_amissl.a(openssl.o): In function `pubkey_show':
/cygdrive/c/!/_development/curl-7.53.1/lib/vtls/openssl.c:2382: undefined reference to `BIO_ctrl'
../../../framework/thirdparty/libcurl/68k/libcurl_amissl.a(openssl.o): In function `X509V3_ext':
/cygdrive/c/!/_development/curl-7.53.1/lib/vtls/openssl.c:2405: undefined reference to `sk_num'
/cygdrive/c/!/_development/curl-7.53.1/lib/vtls/openssl.c:2430: undefined reference to `BIO_free'
../../../framework/thirdparty/libcurl/68k/libcurl_amissl.a(openssl.o): In function `get_cert_chain':
/cygdrive/c/!/_development/curl-7.53.1/lib/vtls/openssl.c:2476: undefined reference to `BIO_ctrl'
/cygdrive/c/!/_development/curl-7.53.1/lib/vtls/openssl.c:2496: undefined reference to `i2a_ASN1_OBJECT'
../../../framework/thirdparty/libcurl/68k/libcurl_amissl.a(openssl.o): In function `pkp_pin_peer_pubkey':
/cygdrive/c/!/_development/curl-7.53.1/lib/vtls/openssl.c:2709: undefined reference to `i2d_X509_PUBKEY'
../../../framework/thirdparty/libcurl/68k/libcurl_amissl.a(openssl.o): In function `servercert':
/cygdrive/c/!/_development/curl-7.53.1/lib/vtls/openssl.c:2791: undefined reference to `ASN1_TIME_print'
/cygdrive/c/!/_development/curl-7.53.1/lib/vtls/openssl.c:2792: undefined reference to `BIO_ctrl'
/cygdrive/c/!/_development/curl-7.53.1/lib/vtls/openssl.c:2818: undefined reference to `X509_free'

i added the followings to libCurl/openssl.c:

#include <proto/amisslmaster.h>
#include <proto/amissl.h>
#include <libraries/amisslmaster.h>
#include <libraries/amissl.h>
#include <amissl/amissl.h>

@Futaura
Copy link
Collaborator

Futaura commented Mar 19, 2017

Looks maybe like you have the non-AmiSSL openssl include dir in the include search path? My advice would be to move the openssl dir elsewhere, and the AmiSSL includes too. Then you could use -IAmiSSL4 or -IOpenSSL-standalone, for example, when compiling.

@anchor76
Copy link
Author

anchor76 commented Mar 20, 2017

yes, curl still saw openssl. i disposed all openssl, and now i have these errors:

/home/anchor/amissl/lib/AmigaOS3/libamisslauto.a()(.data+0x8): multiple definition of `SocketBase'
../../../framework/thirdparty/libcurl/68k/libcurl_amissl.a(amigaos.o)(.data+0x0):/cygdrive/c/!/_development/curl-7.53.1/lib/amigaos.c: first defined here
../../../framework/thirdparty/libcurl/68k/libcurl_amissl.a(openssl.o): In function `Curl_ossl_seed':
/cygdrive/c/!/_development/curl-7.53.1/lib/vtls/openssl.c:231: undefined reference to `RAND_egd'
../../../framework/thirdparty/libcurl/68k/libcurl_amissl.a(openssl.o): In function `servercert':
/cygdrive/c/!/_development/curl-7.53.1/lib/vtls/openssl.c:2829: undefined reference to `PEM_read_X509'
../../../framework/thirdparty/libcurl/68k/libcurl_amissl.a(md5.o)(.text+0x0):/cygdrive/c/!/_development/curl-7.53.1/lib/md5.c: undefined reference to `MD5_Init'
../../../framework/thirdparty/libcurl/68k/libcurl_amissl.a(md5.o)(.text+0x4):/cygdrive/c/!/_development/curl-7.53.1/lib/md5.c: undefined reference to `MD5_Update'
../../../framework/thirdparty/libcurl/68k/libcurl_amissl.a(md5.o)(.text+0x8):/cygdrive/c/!/_development/curl-7.53.1/lib/md5.c: undefined reference to `MD5_Final'
../../../framework/thirdparty/libcurl/68k/libcurl_amissl.a(md5.o)(.text+0x18):/cygdrive/c/!/_development/curl-7.53.1/lib/md5.c: undefined reference to `MD5_Init'
../../../framework/thirdparty/libcurl/68k/libcurl_amissl.a(md5.o)(.text+0x1c):/cygdrive/c/!/_development/curl-7.53.1/lib/md5.c: undefined reference to `MD5_Update'
../../../framework/thirdparty/libcurl/68k/libcurl_amissl.a(md5.o)(.text+0x20):/cygdrive/c/!/_development/curl-7.53.1/lib/md5.c: undefined reference to `MD5_Final'
../../../framework/thirdparty/libcurl/68k/libcurl_amissl.a(rand.o): In function `Curl_rand':
/cygdrive/c/!/_development/curl-7.53.1/lib/rand.c:124: undefined reference to `assert'
collect2: ld returned 1 exit status
make: *** [makefile.amissl:39: "devs/google-drive-handler.68k"] Error 1

  • what about SocketBase? i didn't see in the readme that AmiSSL takes care of it.
  • the md5 errors are really strange, the md5.c getting md5_xxx functions from AmiSSL.
    i have put the AmiSSL include to curl_setup.h so every curl source should use AmiSSL protos&inlines.

@jens-maus
Copy link
Owner

@anchor76 First of all, please use proper GitHub Markdown language to format your posts. I really tend to get eye cancer for all the code you post here without proper escaping it as code passages ;)

Regarding your questions:

  1. You are linking with libamisslauto.a and thus SocketBase is automatically defined. If you don't want that omit using libamisslauto.a and open AmiSSL, etc. yourself.
  2. Regarding the other errors:
    • RAND_egd: is currently not part of the AmiSSL API and I would have to check how hard it would be to include it in the next release
    • PEM_read_X509: This function is using file pointers (fp) and thus we would need to create Amiga typical wrapper functions for it (PEM_read_X509_amiga) which uses a BPTR instead so that this function is compatible between different C-runtime libraries used.
    • MD5_XXXX: These functionss should be indeed part of AmiSSL and work properly. Would be actually good to see your final linker execution command so that we could track down your issues more easily.

@anchor76
Copy link
Author

anchor76 commented Mar 20, 2017

thanks Jens! here is the libCurl makefile:

#
# libcurl Makefile for AmigaOS ...
#

ATCPSDKI  =	/home/anchor/netinclude
AMISSL    = /home/anchor/amissl
LIBZ      = /home/anchor/libz/68k

CC	    =	m68k-amigaos-gcc
MACROS  = -DCURL_DISABLE_FILE -DCURL_DISABLE_NTLM -DBUILDING_LIBCURL -DAMISSL -D__AMIGA__
CFLAGS	= -I$(AMISSL)/include -I$(LIBZ) -I$(ATCPSDKI) -m68020-60 -O2 -msoft-float -noixemul -g -I. -I../include -W -Wall -fno-rtti -fno-exceptions $(MACROS)

include Makefile.inc
OBJS = $(CSOURCES:.c=.o)

all:	$(OBJS)
	ar cru libcurl.a $(OBJS)
	m68k-amigaos-ranlib libcurl.a

install:
	$(INSTALL) -c ./libcurl.a /lib/libcurl.a

and the project makefile:

# Project: google-drive-handler
# Compiler: m68k-amiga-gcc

CURL      = ../../../framework/thirdparty/libcurl/68k
AMISSL    = /home/anchor/amissl
LIBZ      = ../../../framework/thirdparty/libz/68k
FRAMEWORK = ../../../framework/source

CPP       = m68k-amigaos-g++
CC        = m68k-amigaos-gcc
AS        = m68k-amigaos-as
LINK      = m68k-amigaos-g++
OBJ       = ../shared/start_68k.o ../../obj/google_drive_handler.o ../../obj/dos_handler.o ../../obj/fw_util.o
LINKOBJ   = $(OBJ)
LIBS      = -L$(CURL) -L$(AMISSL)/lib/AmigaOS3 -L$(LIBZ) -s -lcurl_amissl -lamisslauto -lz -lnix -lstubs -noixemul -nostartfiles
INCS      = -I$(CURL) -I$(FRAMEWORK)
CXXINCS   = $(INCS)
BIN       = "devs/google-drive-handler.68k"
DEFINES   = -D_CONSOLE -DNO_INLINE_STDARG -DNO_INLINE_VARARGS -D_NOLOG -DAMISSL
CXXFLAGS  = $(CXXINCS) $(DEFINES) -m68020-60 -msoft-float -O2 -fno-rtti -fno-exceptions
CFLAGS    = $(INCS) $(DEFINES) -noixemul
RM        = rm -f

.PHONY: all all-before all-after clean clean-custom
all: all-before $(BIN) all-after

clean: clean-custom
	$(RM) $(OBJ) $(BIN)
	
install:
	cp $(BIN) "../../../users/public/documents/amiga files/winuae/dh1/devs/google/google-drive-handler"

$(BIN): $(OBJ)
	$(LINK) $(LINKOBJ) -o $(BIN) $(LIBS)

../../obj/google_drive_handler.o: $(GLOBALDEPS) google_drive_handler.cpp
	$(CPP) -c google_drive_handler.cpp -o ../../obj/google_drive_handler.o $(CXXFLAGS)

../../obj/dos_handler.o: $(GLOBALDEPS) ../shared/dos_handler.cpp
	$(CPP) -c ../shared/dos_handler.cpp -o ../../obj/dos_handler.o $(CXXFLAGS)

../../obj/fw_util.o: $(GLOBALDEPS) $(FRAMEWORK)/fw_util.cpp
	$(CPP) -c $(FRAMEWORK)/fw_util.cpp -o ../../obj/fw_util.o $(CXXFLAGS)

@anchor76
Copy link
Author

Hello, when can i expect new AmiSSL release with RAND_egd and PEM_read_X509 support? libCurl requires them. Would be good to update my google-drive, and dropbox handlers with AmiSSL support ... :)

@tboeckel
Copy link
Collaborator

For RAND_egd() the situation is quite simple. It can be added, but it will do nothing. There is an empty function which does nothing except returning -1 for AmigaOS, but for Windows, MSDOS and several other systems as well. So adding support for RAND_egd() would be simple, but you would gain nothing.

Regarding PEM_read_X509() Jens already answered this question. Since the typical FILE structures differ between the indivudual C runtime library implementations it is impossible to include this function directly in AmiSSL. Instead we would need a replacement function for AmigaOS only which uses the AmigaDOS file API. But then you still have to take care of calling this special function yourself, because the code of curl will use the C library's FILE pointers instead of the required AmigaDOS BPTR.

@anchor76
Copy link
Author

Ok, its clear. The question is, when can you make a new release?

@jens-maus
Copy link
Owner

@anchor76 Sorry, but I still think you don't understand the implications of these changes. RAND_egd() will be essentially empty and PEM_read_X509() can't be added in a portable way. Thus I would vote against changing anything here. You should better modify your curl patches to 1. not call RAND_egd() as it will anyway just return -1 and then also see if you can replace the use of PEM_read_X509() yourself.

@anchor76
Copy link
Author

Well, yes, the RAND_egd() is not important as you said before its not doing anything. For the PEM_read_X509() a new AmiSSL release would be good with PEM_read_X509_amiga() wrapper.
In March you wrote: "This function is using file pointers (fp) and thus we would need to create Amiga typical wrapper functions for it (PEM_read_X509_amiga) which uses a BPTR instead so that this function is compatible between different C-runtime libraries used."
Now you wrote i need to patch libCurl. It means i should forget the new AmiSSL release?

@Futaura
Copy link
Collaborator

Futaura commented Sep 26, 2017

As @tboeckel eludes to, I don't think is going to be a magic fix for you, even if it were added, without some work on your part anyway (because of the different file i/o interfaces).

Can you not add an extra module to your port with suitable wrappers for unsupported functions? For example, write your own PEM_read_X509() which uses PEM_read_bio_X509() instead? PEM_read_X509() itself is essentially just a wrapper anyway - check the source of PEM_ASN1_read() to see what it does.

@Futaura
Copy link
Collaborator

Futaura commented Sep 26, 2017

Having now had a look at the libcurl source code, it looks to me like the simplest solution for you is to patch openssl.c as PEM_read_X509() is only used once. Replace the area of code starting fopen() and ending fclose(), where PEM_read_X509() is used to avoid using stdio at all and use the OpenSSL BIO interface instead - this is a copy and paste from IBrowse code, as an example:

	X509 *x;
	BIO *in;
	if(in=BIO_new(BIO_s_file()))
	{
		if (BIO_read_filename(in,Name) <= 0)
		{
//			kprintf("Error\n");
			return;
		}
		if(x=PEM_read_bio_X509(in,NULL,NULL,NULL))
		{

@jens-maus
Copy link
Owner

@anchor76 Feel free to contributw to the AmiSSL project in creating these wrappers yourself and sending a pull request. These days qith only 500 users actually using AmiSSL world-wide I would say it is time that all still active Amiga developers start contributinh to other projects than simply requesting a change.

@chris-y
Copy link

chris-y commented Mar 10, 2019

@anchor76 Did you ever get this resolved?
If I try to build Curl against AmiSSL now, I get:

../lib/.libs/libcurl.a()(.text+0x58d6):: undefined reference to `_X509_free'
../lib/.libs/libcurl.a()(.text+0x59be):: undefined reference to `_X509_free'
../lib/.libs/libcurl.a()(.text+0x5bee):: undefined reference to `_X509_free'
../lib/.libs/libcurl.a()(.text+0x0):: undefined reference to `_MD5_Init'
../lib/.libs/libcurl.a()(.text+0x4):: undefined reference to `_MD5_Update'
../lib/.libs/libcurl.a()(.text+0x8):: undefined reference to `_MD5_Final'
../lib/.libs/libcurl.a()(.text+0x14):: undefined reference to `_MD5_Init'
../lib/.libs/libcurl.a()(.text+0x18):: undefined reference to `_MD5_Update'
../lib/.libs/libcurl.a()(.text+0x1c):: undefined reference to `_MD5_Final'

I can't see any reason why these aren't picked up. MD5 I can probably get around by using Curl internal version, but X509_free() is a bit of a problem. It appears to only be used in this one file: https://github.com/curl/curl/blob/master/lib/vtls/openssl.c

@chris-y
Copy link

chris-y commented Mar 10, 2019

OK, I've managed to build it but the curl executable won't connect to any secure sites:

curl: (35) OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to www.howsmyssl.com:443

@anchor76
Copy link
Author

anchor76 commented Mar 11, 2019

no, last time when i tried to compile libCurl with AmiSSL, i had no luck. but i didn't give up. i'll check it again soon. btw: as i remember i had to modify libCurl a little to be able to compile for m68k-amigaos target.

@chris-y
Copy link

chris-y commented Mar 11, 2019

You may want to try my amissl branch at https://github.com/chris-y/curl
This will allow you to do a configure --with-amissl and build without any modifications (hopefully! It's geared up for building against clib2, so there's a possibility it needs some #ifdef clib2 magic if built against something else, even though I tried not to completely break the existing ixemul/libnix stuff)
But, as I say, it doesn't seem to work. If we can fix it I'll do a pull request.

@Futaura
Copy link
Collaborator

Futaura commented Mar 11, 2019

Are you able to obtain a more verbose error message? OpenSSL errors are usually much more descriptive, but not sure if curl can show them?

@chris-y
Copy link

chris-y commented Mar 11, 2019

Sadly not. The source code says:

      /* detail is already set to the SSL error above */

      /* If we e.g. use SSLv2 request-method and the server doesn't like us
       * (RST connection etc.), OpenSSL gives no explanation whatsoever and
       * the SO_ERROR is also lost.
       */

@chris-y
Copy link

chris-y commented Mar 11, 2019

Ah, OK, some of my code was messed up by GCC having a default ixemul define even though this build of GCC has never been near ixemul ☹. I think libcurl is using socket functions from clib2, rather than the global socketbase opened by libamisslauto. I'm trying to fix this but removing the clib2 network functions is causing configure to break, and the amount I know about autoconf can be etched on the pointy side of a pin...

@chris-y
Copy link

chris-y commented Mar 12, 2019

@anchor76
Copy link
Author

anchor76 commented Mar 13, 2019

@chris-y : that's very good! can you please share the static lib and headers too?

@chris-y
Copy link

chris-y commented Mar 14, 2019

@anchor76 Here: https://github.com/chris-y/curl/releases/download/curl-7_64_0-amissl/libcurl.lzh
Just make sure you build anything against it with -lamisslauto (or equivalent code) and use bsdsocket.library directly, not any C lib wrapper.

@anchor76
Copy link
Author

@chris-y : thanks, i tried to compile my handers with your libCurl, but i got this error:
/opt/m68k-amigaos-bebbo/lib/gcc/m68k-amigaos/6.4.1b/../../../../m68k-amigaos/bin/ld: different object file formats composing set ___CTOR_LIST__

this _CTOR_LIST seems coming from amisslauto lib. maybe i can not use amissl with my gcc? (v6.4.1b)

@anchor76
Copy link
Author

ping! :)

do i have chance with gcc 6.4.1b?

@Futaura
Copy link
Collaborator

Futaura commented Apr 23, 2019

Sorry - I'm missing Google Inbox which used to bring GitHub updates to me attention :-(

I don't know the full reason for this error, but have you tried recompiling the autoinit library with 6.4.1b? That should be a solution (other than avoiding the library completely).

@anchor76
Copy link
Author

@chris-y - what gcc version do you have?

@chris-y
Copy link

chris-y commented Jun 21, 2019

3.4.6
I've never managed to get anything newer working for 68k.

@arczi84
Copy link

arczi84 commented Nov 11, 2019

I've compiled AmiSSL with gcc version 6.5.0b 191023121710 (GCC) out of the box with make OS=os3.
When launching NetSurf I get: Couldn't initialize amisslmaster.library!
SnoopDOS says it's loaded.
I'm using @chris-y libcurl.

@Futaura
Copy link
Collaborator

Futaura commented Nov 11, 2019

@arczi84 Why do you need to recompile AmiSSL? Just use the binaries. You will need the correct version of GCC to build AmiSSL, due to baserel issues.

@arczi84
Copy link

arczi84 commented Nov 11, 2019

I only need libamisslauto.a.
Why is this error then ?
Couldn't initialize amisslmaster.library!
Works with gcc 3.4.6.

@arczi84
Copy link

arczi84 commented Nov 11, 2019

Nevermind , tested on system that didn't have AmiSSL4 installed.

@OliverUrbann
Copy link

How did you manage to compile it with 6.5.0b? I have exactly the same problems here (_CTOR_LIST) and therefore have to recompile it. But my gcc 6.5.0b cannot compile the inline assembler:

int64math.c:159:6: error: expected '=', ',', ';', 'asm' or '__attribute__' before '%' token
  subx%.l %3,%0"       \

and many more like this when running

make OS=os3-68020

Or could you provide your libamisslauto.a?

@arczi84
Copy link

arczi84 commented Jul 10, 2020

Maybe that version of gcc6 I used could compile it or I used original clib2 headers ?

http://netsurf.baderman.net/libamisslauto.a

@OliverUrbann
Copy link

OliverUrbann commented Jul 11, 2020

This .a works for me, thx! Seems something has changed in int64math.c. There is no OS=os3 anymore, and all others use inline assembler in int64math.c.

Update: No. It compiles but crashes on start even before main().

@OliverUrbann
Copy link

I have now a solution:

Building curl for amiga

@arczi84
Copy link

arczi84 commented May 15, 2021 via email

@arczi84
Copy link

arczi84 commented May 15, 2021 via email

@OliverUrbann
Copy link

OliverUrbann commented May 15, 2021

Unfortunately I cannot reproduce your error. However, I can confirm the steps described in the blog post still work for AmiSSL 4.9 but only for the mentioned commit (note that it is not my fork), not for master. Interestingly I get different error on curl master:

/opt/m68k-amigaos/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: ../lib/.libs/libcurl.a(libcurl_la-sha256.o): in function `Curl_HMAC_SHA256':
libcurl_la-sha256.o:(.text+0x44): undefined reference to `SHA256_Init'
/opt/m68k-amigaos/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: libcurl_la-sha256.o:(.text+0x48): undefined reference to `SHA256_Update'
/opt/m68k-amigaos/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: libcurl_la-sha256.o:(.text+0x4c): undefined reference to `SHA256_Final'
/opt/m68k-amigaos/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: ../lib/.libs/libcurl.a(libcurl_la-openssl.o):(.text+0x2fc6): undefined reference to `X509_INFO_free'
/opt/m68k-amigaos/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: ../lib/.libs/libcurl.a(libcurl_la-openssl.o):(.text+0x3678): undefined reference to `X509_INFO_free'

So, I think I'll try to get the curl master working again but I don't know if this will be a solution for your problem.

@arczi84
Copy link

arczi84 commented May 15, 2021 via email

@arczi84
Copy link

arczi84 commented May 15, 2021 via email

OliverUrbann pushed a commit to OliverUrbann/curl that referenced this issue May 19, 2021
AmiSSL replaces many functions with macros. Curl requires pointer
to some of these functions. Thus, we have to encapsulate these macros:
SHA256_Init, SHA256_Update, SHA256_Final, X509_INFO_free.

Bug: jens-maus/amissl#15
OliverUrbann added a commit to OliverUrbann/curl that referenced this issue May 20, 2021
AmiSSL replaces many functions with macros. Curl requires pointer
to some of these functions. Thus, we have to encapsulate these macros:
SHA256_Init, SHA256_Update, SHA256_Final, X509_INFO_free.

Bug: jens-maus/amissl#15
OliverUrbann added a commit to OliverUrbann/curl that referenced this issue May 20, 2021
AmiSSL replaces many functions with macros. Curl requires pointer
to some of these functions. Thus, we have to encapsulate these macros:
SHA256_Init, SHA256_Update, SHA256_Final, X509_INFO_free.

Bug: jens-maus/amissl#15
Co-authored-by: Daniel Stenberg <daniel@haxx.se>
bagder pushed a commit to curl/curl that referenced this issue May 20, 2021
AmiSSL replaces many functions with macros. Curl requires pointer
to some of these functions. Thus, we have to encapsulate these macros:
SHA256_Init, SHA256_Update, SHA256_Final, X509_INFO_free.

Bug: jens-maus/amissl#15
Co-authored-by: Daniel Stenberg <daniel@haxx.se>

Closes #7099
@OliverUrbann
Copy link

OliverUrbann commented May 20, 2021

There is an update now in the curl repo so that compilation should work again. I also updated my blog post on how to compile it. I've also added a Dockerfile that builds a container containing curl readily compiled.

@arczi84
Copy link

arczi84 commented May 20, 2021 via email

@arczi84
Copy link

arczi84 commented May 21, 2021 via email

@arczi84
Copy link

arczi84 commented May 23, 2021 via email

@chris-y
Copy link

chris-y commented Jun 8, 2021

I'm not entirely sure this is the right place for this, but since this is discussing building Curl with AmiSSL I'll ask here.

Curl 7.77.0 contains @OliverUrbann's fixes, so this is the one I'm now trying to build.

I updated my NDK to the new 3.2R2 version (not sure this is relevant). Everything else remains the same.

I'm getting lots of these: curl_setup.h:301:1: warning: "__NO_NET_API" redefined

But more importantly undefined references by the bucketload (this is just some of them):

../lib/.libs/libcurl.a(libcurl_la-openssl.o)(.text+0x1bf0):libcurl_la-openssl.o: undefined reference to `_BIO_ctrl'
../lib/.libs/libcurl.a(libcurl_la-openssl.o)(.text+0x1c32):libcurl_la-openssl.o: undefined reference to `_X509_get0_signature'
../lib/.libs/libcurl.a(libcurl_la-openssl.o)(.text+0x1c4a):libcurl_la-openssl.o: undefined reference to `_X509_get_X509_PUBKEY'
../lib/.libs/libcurl.a(libcurl_la-openssl.o)(.text+0x1c62):libcurl_la-openssl.o: undefined reference to `_X509_PUBKEY_get0_param'
../lib/.libs/libcurl.a(libcurl_la-openssl.o)(.text+0x1c76):libcurl_la-openssl.o: undefined reference to `_X509_get0_extensions'
../lib/.libs/libcurl.a(libcurl_la-openssl.o)(.text+0x1c80):libcurl_la-openssl.o: undefined reference to `_OPENSSL_sk_num'
../lib/.libs/libcurl.a(libcurl_la-openssl.o)(.text+0x1c96):libcurl_la-openssl.o: undefined reference to `_OPENSSL_sk_num'
../lib/.libs/libcurl.a(libcurl_la-openssl.o)(.text+0x1ca8):libcurl_la-openssl.o: undefined reference to `_OPENSSL_sk_value'
../lib/.libs/libcurl.a(libcurl_la-openssl.o)(.text+0x1cb2):libcurl_la-openssl.o: undefined reference to `_BIO_s_mem'
../lib/.libs/libcurl.a(libcurl_la-openssl.o)(.text+0x1cba):libcurl_la-openssl.o: undefined reference to `_BIO_new'
../lib/.libs/libcurl.a(libcurl_la-openssl.o)(.text+0x1cca):libcurl_la-openssl.o: undefined reference to `_X509_EXTENSION_get_object'
../lib/.libs/libcurl.a(libcurl_la-openssl.o)(.text+0x1cd8):libcurl_la-openssl.o: undefined reference to `_i2t_ASN1_OBJECT'
../lib/.libs/libcurl.a(libcurl_la-openssl.o)(.text+0x1ce8):libcurl_la-openssl.o: undefined reference to `_X509V3_EXT_print'
../lib/.libs/libcurl.a(libcurl_la-openssl.o)(.text+0x1d26):libcurl_la-openssl.o: undefined reference to `_BIO_free'
../lib/.libs/libcurl.a(libcurl_la-openssl.o)(.text+0x1d32):libcurl_la-openssl.o: undefined reference to `_OPENSSL_sk_num'
../lib/.libs/libcurl.a(libcurl_la-openssl.o)(.text+0x1d42):libcurl_la-openssl.o: undefined reference to `_X509_get0_notBefore'
../lib/.libs/libcurl.a(libcurl_la-openssl.o)(.text+0x1d4c):libcurl_la-openssl.o: undefined reference to `_ASN1_TIME_print'
../lib/.libs/libcurl.a(libcurl_la-openssl.o)(.text+0x1d5e):libcurl_la-openssl.o: undefined reference to `_BIO_ctrl'
../lib/.libs/libcurl.a(libcurl_la-openssl.o)(.text+0x1d90):libcurl_la-openssl.o: undefined reference to `_X509_get0_notAfter'
../lib/.libs/libcurl.a(libcurl_la-openssl.o)(.text+0x1d9a):libcurl_la-openssl.o: undefined reference to `_ASN1_TIME_print'
../lib/.libs/libcurl.a(libcurl_la-openssl.o)(.text+0x1dd8):libcurl_la-openssl.o: undefined reference to `_X509_get_pubkey'
../lib/.libs/libcurl.a(libcurl_la-openssl.o)(.text+0x1de8):libcurl_la-openssl.o: undefined reference to `_EVP_PKEY_id'
../lib/.libs/libcurl.a(libcurl_la-openssl.o)(.text+0x1e08):libcurl_la-openssl.o: undefined reference to `_EVP_PKEY_free'
../lib/.libs/libcurl.a(libcurl_la-openssl.o)(.text+0x1e32):libcurl_la-openssl.o: undefined reference to `_BIO_printf'
../lib/.libs/libcurl.a(libcurl_la-openssl.o)(.text+0x1e80):libcurl_la-openssl.o: undefined reference to `_PEM_write_bio_X509'
../lib/.libs/libcurl.a(libcurl_la-openssl.o)(.text+0x1ec8):libcurl_la-openssl.o: undefined reference to `_BIO_free'
../lib/.libs/libcurl.a(libcurl_la-openssl.o)(.text+0x1ed6):libcurl_la-openssl.o: undefined reference to `_X509_EXTENSION_get_data'
../lib/.libs/libcurl.a(libcurl_la-openssl.o)(.text+0x1ee0):libcurl_la-openssl.o: undefined reference to `_ASN1_STRING_print'
../lib/.libs/libcurl.a(libcurl_la-openssl.o)(.text+0x1f16):libcurl_la-openssl.o: undefined reference to `_BIO_free'
../lib/.libs/libcurl.a(libcurl_la-openssl.o)(.text+0x1f28):libcurl_la-openssl.o: undefined reference to `_i2a_ASN1_OBJECT'
../lib/.libs/libcurl.a(libcurl_la-openssl.o)(.text+0x1f6c):libcurl_la-openssl.o: undefined reference to `_i2a_ASN1_OBJECT'
../lib/.libs/libcurl.a(libcurl_la-openssl.o)(.text+0x1fb2):libcurl_la-openssl.o: undefined reference to `_BIO_puts'
../lib/.libs/libcurl.a(libcurl_la-openssl.o)(.text+0x1fc0):libcurl_la-openssl.o: undefined reference to `_EVP_PKEY_get0_RSA'

This is with AmiSSL 4.4, 4.9 was doing the same thing but I reverted back in case that was causing the problem (it wasn't).

I can't remember when this last built, but it was probably around the time of my previous comment on this issue.

Any ideas why this might be happening?

@OliverUrbann
Copy link

Never saw one of these. I‘d suggest to start with my docker container and then replacing things step by step with your desired setup: NDK, compiler, configure command etc.

@chris-y
Copy link

chris-y commented Jun 8, 2021

I wiped everything out and started again, and I think the problem is that the 3.2 NDK doesn't have the GCC inlines in it 😠. I didn't notice before as I'd stuffed it on top of the old one.
I was under the impression it was "ready to go" for most compilers including GCC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants