@NikiC I can't explain it, but I started writing a question for server fault, and to get the error message I ran ./configure --with-openssl, and it's been working ever since :D
Google suggested installing openssl-dev, but 12.04 has no such package. I also found a hint to install libcurl4-openssl-dev, but it didn't help either.
I'm trying to build php5.4.4 on ubuntu 12.04. I have openssl and libssl-dev installed, but if I add --with-openssl to the configure parameters I get: "Cannot find OpenSSL's libraries". If I try with --with-openssl=/usr/include/openssl I get "Cannot find OpenSSL's <evp.h>". Can someone help?