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 · 32 comments

Comments

Projects
None yet
5 participants
@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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Owner

jens-maus commented Mar 19, 2017

@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

This comment has been minimized.

Copy link
Author

anchor76 commented Mar 19, 2017

ok, thanks guys ;)

@anchor76

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Owner

jens-maus commented Mar 20, 2017

@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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Author

anchor76 commented Sep 25, 2017

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

This comment has been minimized.

Copy link
Collaborator

tboeckel commented Sep 26, 2017

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

This comment has been minimized.

Copy link
Author

anchor76 commented Sep 26, 2017

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

@jens-maus

This comment has been minimized.

Copy link
Owner

jens-maus commented Sep 26, 2017

@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

This comment has been minimized.

Copy link
Author

anchor76 commented Sep 26, 2017

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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Owner

jens-maus commented Sep 26, 2017

@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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

Copy link

chris-y commented Mar 12, 2019

@anchor76

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Author

anchor76 commented Mar 14, 2019

@chris-y : thanks, i'll try it. is it compiled with -noixemul and with zlib support?

@chris-y

This comment has been minimized.

Copy link

chris-y commented Mar 14, 2019

It was built for clib2, as follows:

  Host setup:       m68k-unknown-amigaos
  Install prefix:   /opt/netsurf/m68k-unknown-amigaos/env
  Compiler:         /opt/netsurf/m68k-unknown-amigaos/cross/bin/m68k-unknown-amigaos-gcc
   CFLAGS:          -Werror-implicit-function-declaration -O2 -Wno-system-headers
   CPPFLAGS:        -isystem /opt/netsurf/m68k-unknown-amigaos/env/include -isystem /opt/netsurf/m68k-unknown-amigaos/cross/m68k-unknown-amigaos/netinclude -D__NO_NET_API -I/opt/netsurf/m68k-unknown-amigaos/env/include
   LDFLAGS:         -L/opt/netsurf/m68k-unknown-amigaos/env/lib -L/opt/netsurf/m68k-unknown-amigaos/env/lib
   LIBS:            -lamisslauto -lz -lm

  curl version:     7.64.1-DEV
  SSL:              enabled (AmiSSL)
  SSH:              no      (--with-libssh2)
  zlib:             enabled
  brotli:           no      (--with-brotli)
  GSS-API:          no      (--with-gssapi)
  TLS-SRP:          no      (--enable-tls-srp)
  resolver:         default (--enable-ares / --enable-threaded-resolver)
  IPv6:             enabled
  Unix sockets:     no      (--enable-unix-sockets)
  IDN:              no      (--with-{libidn2,winidn})
  Build libcurl:    Shared=no, Static=yes
  Built-in manual:  enabled
  --libcurl option: enabled (--disable-libcurl-option)
  Verbose errors:   enabled (--disable-verbose)
  Code coverage:    disabled
  SSPI:             no      (--enable-sspi)
  ca cert bundle:   no
  ca cert path:     
  ca fallback:      
  LDAP:             no      (--enable-ldap / --with-ldap-lib / --with-lber-lib)
  LDAPS:            no      (--enable-ldaps)
  RTSP:             enabled
  RTMP:             no      (--with-librtmp)
  Metalink:         no      (--with-libmetalink)
  PSL:              no      (libpsl not found)
  Alt-svc:          no      (--enable-alt-svc)
  HTTP2:            disabled (--with-nghttp2)
  Protocols:        DICT FILE FTP FTPS GOPHER HTTP HTTPS IMAP IMAPS POP3 POP3S RTSP SMTP SMTPS TELNET TFTP
  Features:         SSL libz

If you need something else it should build easily from my fork.

@anchor76

This comment has been minimized.

Copy link
Author

anchor76 commented Mar 17, 2019

@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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.