#Building ZLS on FreeBSD - "error: TlsInitializationFailed"

1 messages · Page 1 of 1 (latest)

cyan plover
#

I have compiled zig with Debug rather than Release. My zig version is 0.11.0-dev.2645+2d41dac57. Here is an updated output. Any suggestions would appreciated it. Thank you.

error: TlsInitializationFailed
/home/dan/.local/zig/build/zig/lib/std/crypto/tls/Client.zig:560:49: 0x4424989 in init__anon_120372 (zig)
                                .certificate => return error.TlsCertificateNotVerified,
                                                ^
/home/dan/.local/zig/build/zig/lib/std/http/Client.zig:919:17: 0x40b9c64 in connect (zig)
                return error.TlsInitializationFailed;
                ^
/home/dan/.local/zig/build/zig/lib/std/http/Client.zig:994:23: 0x3e6a651 in request (zig)
        .connection = try client.connect(host, port, protocol),
                      ^
/home/dan/.local/zig/build/zig/src/Package.zig:482:19: 0x3e68799 in fetchAndUnpack (zig)
        var req = try http_client.request(uri, .{}, .{});
                  ^
/home/dan/.local/zig/build/zig/src/Package.zig:282:25: 0x3e6de54 in fetchAndAddDependencies (zig)
        const sub_pkg = try fetchAndUnpack(
                        ^
/home/dan/.local/zig/build/zig/src/main.zig:4402:13: 0x3cba69e in cmdBuild (zig)
            try fetch_result;
            ^
/home/dan/.local/zig/build/zig/src/main.zig:298:9: 0x3c843d1 in mainArgs (zig)
        return cmdBuild(gpa, arena, cmd_args);
        ^
/home/dan/.local/zig/build/zig/src/main.zig:211:5: 0x3c82cde in main (zig)
    return mainArgs(gpa, arena, args);
    ^
#

Building ZLS on FreeBSD - "error: TlsCertificateNotVerified"

cyan plover
#

Building ZLS on FreeBSD - "error: TlsInitializationFailed"

fluid scaffold
#

I am getting same error on Windows 11 64bit AMD with Debug build latest git clone hash a774f9334473822fd7c6c828dd3fb873788b2f72 as well (as on Apr 20). Is there anyone else facing same issue? BTW, I get this error when trying to build zls: https://github.com/zigtools/zls.
When I build a project from scratch (that is created with zig init-exe) then I don't get an error. I am a beginner, so apologies in advance for not being able to debug this in first attempt.

zig version
0.11.0-dev.2703+a774f9334

fierce oar
#

catching the actual error on the tls client init shows that it throws CertificateExpired for github.com, which is strange

#

It looks like github updated their old certificate in mid Feb and our certificates stores have the old one stored which expired yesterday

fluid scaffold
#

Thanks @fierce oar . I am curious if there is an option to dump detailed logs to debug such scenarios.

fierce oar
#

I just added some std.debug.print statements and compiled then ran my built version

fluid scaffold
#

Ah! where did you add the print? Did you add the print in compiler (zig)?

#

ah! probably in Client.zig:994:23.

#

Thanks for debugging this. Any suggestion for workaround or do we have to wait for final fix?

fierce oar
#

The issue is most likely not with zig, but with windows. The certificate have to be updated in the certificate store. still trying to figure out how to do that

fluid scaffold
#

hmm... Interesting.

fluid scaffold
#

noticed that ninja install or even ninja install -j 10 doesnt help with build time on windows. Only single instance of zig\build-debug\zig2.exe does the build for zig compiler and that uses a very small CPU timeslice.

I am trying to add some traces to compiler for understanding the error like Draagren indicated. Good learning for me as well.

fierce oar
#

I dont use the ninja way, but with the devkit instead

#

and then option 1b

fluid scaffold
#

checking

fierce oar
#

hmm, it may look like we actually try to get the RSA certificate which is no longer valid, while the new one is issued using ECC

fluid scaffold
# fierce oar https://github.com/ziglang/zig/wiki/Building-Zig-on-Windows

Tried it. Looks like "Semantic Analysis" (as per build command display, see below) is sequential, because the build is still single process, but build errors (because I made a mistake) is much nicer probably because I patched zig in devkit with my previous version which was from master.
steps [5/8] zig build-exe zig Debug x86_64-windows-gnu... Semantic Analysis [24212] xor.

fierce oar
#

got it working ish

#

tls/Client.zig comment out line 171 -> 176

#

ie if we ask github for an rsa certificate it will give us the old one, which is outdated instead of the esdsa one

fluid scaffold
#

which cert is this?

fierce oar
#

"DigiCert TLS RSA SHA256 2020 CA1 - github.com" is the wrong one we get with rsa extensions enabled

#

"DigiCert TLS Hybrid ECC SHA384 2020 CA1 - *.github.com" is the one we want

fluid scaffold
#

ok

#

sidenote: when I use D:\zig-devkit\bin\zig build -p stage3 --search-prefix D:\zig-devkit --zig-lib-dir lib -Dstatic-llvm -Duse-zig-libcxx -Dtarget=x86_64-windows-gnu after downloading devkit to D:\zig-devkit and patching zig.exe from latest master download release to D:\zig-devkit\bin then I get a strange error.

run docgen (langref.html): error: error: unable to open zig lib directory 'lib': FileNotFound

The following command exited with code 1:
D:\zig-devkit\bin\zig.exe build-exe --name hello --color on hello.zig --zig-lib-dir lib
D:\Work\git\ziglang\zig\doc\langref.html.in:402:31: error: example failed to compile
{#code_begin|exe|hello#}

fierce oar
#

yeah you need to specify lib

#

here is my command

#

C:\Git\zigcode\devkit\kit-0110dev1869df4cfc2ec\bin\zig.exe build -p build/stage3 --search-prefix "C:\Git\zigcode\devkit\kit-0110dev1869df4cfc2ec" --zig-lib-dir C:\Git\zigcode\zig\lib -Dstatic-llvm -Duse-zig-libcxx -Dtarget=x86_64-windows-gnu

fluid scaffold
#

interesting. So the --zig-lib-dir <whatever> is the lib for the source zig which is being built.

#

I'll attempt a PR for fixing the docs if that works

#

It did work and the folder for lib must be absolute path as well.

fierce oar
#

yeah

fluid scaffold
#

the build is still not parallel though. I am not sure if there is some setting which I must do or inherent of the zig project itself.

#

Ah! found it. In zig/build.zig:44 it says single threaded docgen_exe.single_threaded = single_threaded;. It makes sense now that docgen is blocking the build.

fierce oar
#

openssl s_client -tls1_2 -connect github.com:443 -sigalgs "RSA+SHA256" certificate expired this is the issue

rancid geyser
#

I got this earlier and asked about it on the zls Discord channel. Good thing if the reason is found. I am still not sure what exactly we are doing over the network here... Is Zig itself downloading something from github, or is this a zls thing? Or the package manager or what? I was under the impression that the build process is a purely local process.

fierce oar
#

if zls has started to use the new package manager then yes it will download dependencies when building

#

and github gives us a certificate that expired yesterday when we try to do TLS connection

#

yeah, zls has 3 external dependenices it will try to fetch from github when building

rancid geyser
#

I see, thanks for the explanation!

fierce oar
#

There is also a second bug which causes a crash even if you get a valid connection. Something in Headers.zig deinit() has some malformed memory which kills the program when it tries to deinit the connection afterwards

rancid geyser
#

Ah, it's the zon file