I have installed libffi on my Linux server as well as correctly set the PKG_CONFIG_PATH environment variable to the correct directory, as pip
pip packages usually don't use pkg-config. Therefore, you should set CFLAGS and LDFLAGS manually:
CFLAGS=$(pkg-config --cflags libffi) LDFLAGS=$(pkg-config --libs libffi) pip install pyOpenSSL
You need to install the development package as well.
libffi-dev on Debian/Ubuntu, libffi-devel on Redhat/Centos/Fedora.