www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - openssl 1.1 vs. 3.0 for vibe.d:tls on Ubuntu 22.04

reply Guillaume Lathoud <gsub glat.info> writes:
Hello, some context first:

I recently updated a server to Ubuntu 22.04 which appears to have 
only openssl 3.0.2 installed. Dub could compile my project, but 
could not link it anymore, as the D code seemed to be expecting 
openssl 1.1 whereas only 3.0.2 was installed. That type of errors:
```
/usr/bin/ld: 
...../vibe-d-0.9.6/vibe-d/tls/vibe/stream/openssl.d:370: 
undefined reference to `SSL_get_peer_certificate'
/usr/bin/ld: 
...../vibe-d-0.9.6/vibe-d/tls/vibe/stream/openssl.d:1485: 
undefined reference to `ERR_put_error'
collect2: error: ld returned 1 exit status
```
I tried various things, including all possible `subConfiguration` 
values for `vibe-d:tls`, and ended up:

(1) selecting `"vibe-d:tls": "openssl-1.1"`

(2) compiling openssl-1.1 from source following  
https://askubuntu.com/a/1458747

(3) symlinking the resulting files `libssl.a` and `libcrypto.a` 
into LDC's `lib` directory, since libs under that dir seem to 
have precedence over the system libs, as visible in the 
`/usr/bin/cc` call triggered by DUB.

Then  the project compiled again.

.

Now to the actual question:

I am a bit confused since the source code of `vibe-d:tls` seem to 
support openssl-3.0, as visible e.g. in [1] but then in the 
config [2] I don't see anything like `"openssl-3.0"`. Maybe I 
missed something obvious!

[1] 
https://github.com/vibe-d/vibe.d/blob/master/tls/vibe/stream/openssl.d#L198
[2] https://github.com/vibe-d/vibe.d/blob/master/tls/dub.sdl

Could anyone please shed some light on a cleaner solution to get 
`vibe.d:tls` running on Ubuntu 22.04, esp. to get it running with 
openssl-3.0+?

Thanks in advance,
Guillaume

.

For info, the project has the following `dub.json` config:
```
...
        "dependencies": {
                 "dub": "~>1.33.1",
                 "openssl": "~>3.3",
                 "vibe-d": "~>0.9.6",
                 "vibe-d:tls": "~>0.9.6"
         },                                                        
                                                                   
                                                          ...
         "libs": [
                 "curl"
         ],
...
        "subConfigurations": {
             "vibe-d:tls": "openssl-1.1"
         },
         "versions": [
                 "VibeDefaultMain"
         ]
...
```
Jul 28 2023
parent janrinok <janrinok protonmail.com> writes:
On Friday, 28 July 2023 at 08:56:17 UTC, Guillaume Lathoud wrote:
 Hello, some context first:

 I recently updated a server to Ubuntu 22.04 which appears to 
 have only openssl 3.0.2 installed. Dub could compile my 
 project, but could not link it anymore, as the D code seemed to 
 be expecting openssl 1.1 whereas only 3.0.2 was installed. That 
 type of errors:
 ```
 /usr/bin/ld: 
 ...../vibe-d-0.9.6/vibe-d/tls/vibe/stream/openssl.d:370: 
 undefined reference to `SSL_get_peer_certificate'
 /usr/bin/ld: 
 ...../vibe-d-0.9.6/vibe-d/tls/vibe/stream/openssl.d:1485: 
 undefined reference to `ERR_put_error'
 collect2: error: ld returned 1 exit status
 ```
 I tried various things, including all possible 
 `subConfiguration` values for `vibe-d:tls`, and ended up:

 [...]
Did you ever get this problem resolved? I have just found the same issue and cannot get vibe.d to compile cleanly - it reports "Invalid variable: DC" when trying to compile "openssl-static": "1.0.2+3.0.8",
Dec 12 2023