OpenSSL errors

This morning, all of my server-side Swift apps stopped working... The exact same code that has been running fine for 6 months suddenly stopped compiling. None of the packages that depend on OpenSSL (MongoKitten, IBM-Swift/OpenSSL, swift-nio-ssl) compile anymore. They all show errors like:

use of undeclared type 'SSL'
use of undeclared type 'SSL_METHOD'
use of unresolved identifier 'SSL_CTRL_OPTIONS

and so on.

These are all Swift 4.2 apps running on IBM Cloud.

I've tried upgrading to Swift 5.0 (on macOS), but that results in similar errors complaining about missing openssl headers.

What's going on here?

As we discussed in the Kitura Slack that seems to be an incompatibility with OpenSSL 1.1. In C, a package can mostly use the same code for OpenSSL 1.0 and OpenSSL 1.1 as they are largely source compatible in C. In Swift however, they're not source compatible at all as discussed in for example this thread. This means that almost all packages written against OpenSSL 1.0 will not work with OpenSSL 1.1. As swift-nio-ssl version 1.x demonstrates, it is possible to write Swift code that works with both OpenSSL 1.0 and 1.1 but it's very painful.

Your particular issue seems to stem from the fact that IBM Cloud updated from Ubuntu 14.04 (OpenSSL 1.0) to Ubuntu 18.04 (OpenSSL 1.1) which will break all Swift programs that only work with OpenSSL 1.0.

Because this is all such a pain (and also not future-proof), the SwiftNIO team decided that starting from swift-nio-ssl version 2.0 we will no longer depend on the system's OpenSSL version and bring our own namespaced version of BoringSSL instead. This is fully implemented, shipped with SwiftNIO 2.0 in March 2019 and the process was discussed in this post.

1 Like