sys.ssl.Socket broken in cpp build on macOS, unless -debug compiler option is included

Simple code:

class Main {
	static function main() {
		var socket = new sys.ssl.Socket();
		socket.connect(new""), 443);
		trace("handshake succeeded");

Debug build:

haxe -cp src -main Main -debug -cpp out

If I run ./out/Main-debug in a terminal, I see the expected “handshake succeeded” in the terminal.

Release build:

haxe -cp src -main Main -cpp out

If I run ./out/Main in a terminal, the output is an exception:

Error : X509 - Certificate verification failed, e.g. CRL, CA or signature check failed

On Windows, it works fine.

Haxe 4.2.5
hxcpp 4.2.1
macOS Ventura 13.0.1 (M1 Apple Silicon)

Am I doing something wrong?

1 Like

Would I report the bug to the HaxeFoundation/haxe repo, since it is part of the standard library? Or, since this affects c++ builds only, would I report a bug to HaxeFoundation/hxcpp instead?

I can reproduce this.
I am suspicious it’s a linking issue though since the only file that has changes between the debug build and release build is HxcppConfig.h. :thinking:

I’m also on Ventura and M1, I’ll poke around and see what I can find.

1 Like

Well copying the SSL (This is the name of whatever your --main is) and SSL.hash from the debug build into the release folder and compiling fixes the issue. I’ll see where that file is coming from.

Can you tell I had a long day at work when I wrote that non-sense? Anyway still digging through this, if I can’t figure out a workaround for you I’ll open an issue on hxcpp and link it here.


Well Josh I’m not quite sure what the issue is so far, I’ll have some time this weekend to take another look. I’ve verified that I can only produce this issue on MacOS. Also the release and debug build both obtain the same default certs from mbedtls. SSL.cpp doesn’t have any debug specific logic in it as far as I can tell. :melting_face:

I’ll open an issue on hxcpp in the morning, unless you beat me to it.

I’ve opened an issue for this here:

1 Like

@davidbruce Thanks for looking into it! Really tricky issue, it seems.

@joshtynjala It looks like Hugh has a fix for this, could you verify that the changes in develop work for you?

1 Like

I confirm that these hxcpp changes work for me. Thank you for the help, @davidbruce!