Building py-cryptography on OpenBSD 6.3 (libressl 2.7.x)

Tuesday July 03, 2018 by cl0secall

Was trying to upgrade NetBox and the upgrade script bailed while installing cryptography. I've had issues with the cryptography package in the past, since they use some obscure compiler flags that are only available on newer compilers. Once OpenBSD switched to clang/llvm as the default compiler I thought I'd be out of the woods, but it seems that the cryptography module only targets OpenSSL for compatibility, not LibreSSL. There's some patching currently in the works but as of version 2.2.2 of the package I had to use a workaround: install OpenSSL.

The nitty-gritty:

  • Install OpenSSL
  • Set CFLAGS and LDFLAGS to point to the OpenSSL that I installed
$ pkg_add -i openssl  
...  
$ export CFLAGS=-I/usr/local/include/eopenssl  
$ export LDFLAGS=-L/usr/local/lib/eopenssl -lssl -lcrypto  
$ pip install -U cryptography  
...

Good luck.