Treat OpenSSL as a non-portable include
authorChristopher Dykes <cdykes@fb.com>
Tue, 11 Apr 2017 21:17:10 +0000 (14:17 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Tue, 11 Apr 2017 21:20:08 +0000 (14:20 -0700)
Summary: On Windows, the OpenSSL headers have to be included in a specific order relative to WinSock. Fixing the issues ad-hock is not a viable way to continue, so treat it as completely non-portable and require all includes of it in Folly to go through the portability header.

Reviewed By: yfeldblum

Differential Revision: D4856858

fbshipit-source-id: 56aca1fb0fe095f41a8af12488c6c2080344603d

16 files changed:
folly/io/async/AsyncSSLSocket.cpp
folly/io/async/AsyncTransport.h
folly/io/async/SSLContext.cpp
folly/io/async/SSLContext.h
folly/io/async/ssl/OpenSSLPtrTypes.h
folly/io/async/ssl/OpenSSLUtils.cpp
folly/io/async/ssl/OpenSSLUtils.h
folly/io/async/ssl/test/SSLErrorsTest.cpp
folly/io/async/test/AsyncSSLSocketTest.cpp
folly/io/async/test/AsyncSocketExceptionTest.cpp
folly/portability/OpenSSL.h
folly/ssl/OpenSSLCertUtils.cpp
folly/ssl/OpenSSLCertUtils.h
folly/ssl/OpenSSLHash.h
folly/ssl/OpenSSLVersionFinder.h
folly/ssl/test/OpenSSLCertUtilsTest.cpp

index f8e315f..8c7ab10 100644 (file)
@@ -22,9 +22,6 @@
 #include <boost/noncopyable.hpp>
 #include <errno.h>
 #include <fcntl.h>
-#include <openssl/err.h>
-#include <openssl/asn1.h>
-#include <openssl/ssl.h>
 #include <sys/types.h>
 #include <chrono>
 
index 6505c28..d20831f 100644 (file)
 #include <folly/io/async/DelayedDestruction.h>
 #include <folly/io/async/EventBase.h>
 #include <folly/io/async/ssl/OpenSSLPtrTypes.h>
+#include <folly/portability/OpenSSL.h>
 #include <folly/portability/SysUio.h>
 
-#include <openssl/ssl.h>
-
 constexpr bool kOpenSslModeMoveBufferOwnership =
 #ifdef SSL_MODE_MOVE_BUFFER_OWNERSHIP
   true
index f3ca89f..76bb4aa 100644 (file)
 
 #include "SSLContext.h"
 
-#include <openssl/err.h>
-#include <openssl/rand.h>
-#include <openssl/ssl.h>
-#include <openssl/x509v3.h>
-
 #include <folly/Format.h>
 #include <folly/Memory.h>
 #include <folly/Random.h>
index 07fec1c..f4a638e 100644 (file)
 #include <string>
 #include <random>
 
-// This has to come before SSL.
-#include <folly/portability/OpenSSL.h>
-#include <folly/portability/Sockets.h>
-
-#include <openssl/ssl.h>
-#include <openssl/tls1.h>
-
 #include <glog/logging.h>
 
 #ifndef FOLLY_NO_CONFIG
@@ -40,6 +33,7 @@
 #include <folly/Range.h>
 #include <folly/io/async/ssl/OpenSSLPtrTypes.h>
 #include <folly/io/async/ssl/OpenSSLUtils.h>
+#include <folly/portability/OpenSSL.h>
 
 namespace folly {
 
index ee0bf13..c465fc1 100644 (file)
 
 #include <glog/logging.h>
 
-// This needs to be before any OpenSSL includes.
-#include <folly/portability/OpenSSL.h>
-
-#include <openssl/asn1.h>
-#include <openssl/bio.h>
-#include <openssl/bn.h>
-#ifndef OPENSSL_NO_EC
-#include <openssl/ec.h>
-#include <openssl/ecdsa.h>
-#endif
-#include <openssl/evp.h>
-#include <openssl/hmac.h>
-#include <openssl/rsa.h>
-#include <openssl/ssl.h>
-#include <openssl/x509.h>
-
 #include <folly/Memory.h>
+#include <folly/portability/OpenSSL.h>
 
 namespace folly {
 namespace ssl {
index db25b8b..67cc119 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 #include <folly/io/async/ssl/OpenSSLUtils.h>
-#include <folly/ScopeGuard.h>
-#include <folly/portability/OpenSSL.h>
-#include <folly/portability/Sockets.h>
+
 #include <glog/logging.h>
-#include <openssl/bio.h>
-#include <openssl/err.h>
-#include <openssl/rand.h>
-#include <openssl/ssl.h>
-#include <openssl/x509v3.h>
+
 #include <unordered_map>
 
+#include <folly/ScopeGuard.h>
+#include <folly/portability/Sockets.h>
+
 namespace {
 #ifdef OPENSSL_IS_BORINGSSL
 // BoringSSL doesn't (as of May 2016) export the equivalent
index 877df15..9013592 100644 (file)
 
 #include <folly/Range.h>
 #include <folly/io/async/ssl/OpenSSLPtrTypes.h>
+#include <folly/portability/OpenSSL.h>
 #include <folly/portability/Sockets.h>
 
-#include <openssl/ssl.h>
-#include <openssl/x509v3.h>
-
 namespace folly {
 namespace ssl {
 
index 14dacbe..e07b552 100644 (file)
@@ -17,9 +17,7 @@
 #include <folly/io/async/ssl/SSLErrors.h>
 
 #include <folly/portability/GTest.h>
-
-#include <openssl/err.h>
-#include <openssl/x509.h>
+#include <folly/portability/OpenSSL.h>
 
 using namespace testing;
 using namespace folly;
index 7235992..bc42103 100644 (file)
@@ -15,9 +15,8 @@
  */
 #include <folly/io/async/test/AsyncSSLSocketTest.h>
 
-#include <signal.h>
-
 #include <folly/SocketAddress.h>
+#include <folly/io/Cursor.h>
 #include <folly/io/async/AsyncSSLSocket.h>
 #include <folly/io/async/EventBase.h>
 #include <folly/portability/GMock.h>
 #include <folly/io/async/test/BlockingSocket.h>
 
 #include <fcntl.h>
-#include <folly/io/Cursor.h>
-#include <openssl/bio.h>
+#include <signal.h>
 #include <sys/types.h>
 #include <sys/utsname.h>
+
 #include <fstream>
 #include <iostream>
 #include <list>
index 87ad6af..277fd79 100644 (file)
@@ -17,9 +17,9 @@
 
 #include <folly/io/async/AsyncSocketException.h>
 #include <folly/io/async/ssl/SSLErrors.h>
-#include <folly/portability/GTest.h>
 
-#include <openssl/ssl.h>
+#include <folly/portability/GTest.h>
+#include <folly/portability/OpenSSL.h>
 
 using namespace testing;
 
index d392578..d5d0b0f 100644 (file)
 
 #include <folly/Portability.h>
 
+#include <openssl/opensslv.h>
+
+#include <openssl/asn1.h>
+#include <openssl/bio.h>
+#include <openssl/crypto.h>
 #include <openssl/dh.h>
+#include <openssl/err.h>
 #include <openssl/evp.h>
+#include <openssl/hmac.h>
+#include <openssl/rand.h>
+#include <openssl/rsa.h>
+#include <openssl/sha.h>
 #include <openssl/ssl.h>
+#include <openssl/tls1.h>
 #include <openssl/x509.h>
+#include <openssl/x509v3.h>
+
+#ifndef OPENSSL_NO_EC
+#include <openssl/ec.h>
+#include <openssl/ecdsa.h>
+#endif
 
 // BoringSSL doesn't have notion of versioning although it defines
 // OPENSSL_VERSION_NUMBER to maintain compatibility. The following variables are
index 238fa68..79800df 100644 (file)
  * limitations under the License.
  */
 #include <folly/ssl/OpenSSLCertUtils.h>
-#include <folly/String.h>
-#include <folly/io/async/ssl/OpenSSLPtrTypes.h>
-
-#include <openssl/x509.h>
-#include <openssl/x509v3.h>
 
 #include <folly/ScopeGuard.h>
+#include <folly/String.h>
+#include <folly/io/async/ssl/OpenSSLPtrTypes.h>
 
 namespace folly {
 namespace ssl {
index c6c3803..be8fbec 100644 (file)
@@ -18,9 +18,8 @@
 #include <string>
 #include <vector>
 
-#include <openssl/x509.h>
-
 #include <folly/Optional.h>
+#include <folly/portability/OpenSSL.h>
 
 namespace folly {
 namespace ssl {
index 5d11e3b..baf9ec7 100644 (file)
 
 #pragma once
 
-#include <folly/io/async/ssl/OpenSSLPtrTypes.h>
-#include <folly/portability/OpenSSL.h>
-#include <openssl/evp.h>
-#include <openssl/hmac.h>
-#include <openssl/sha.h>
-
 #include <folly/Range.h>
 #include <folly/io/IOBuf.h>
+#include <folly/io/async/ssl/OpenSSLPtrTypes.h>
+#include <folly/portability/OpenSSL.h>
 
 namespace folly {
 namespace ssl {
index d826e70..19914f9 100644 (file)
@@ -18,9 +18,6 @@
 #include <folly/Conv.h>
 #include <folly/portability/OpenSSL.h>
 
-#include <openssl/crypto.h>
-#include <openssl/opensslv.h>
-
 // This is used to find the OpenSSL version at runtime. Just returning
 // OPENSSL_VERSION_NUMBER is insufficient as runtime version may be different
 // from the compile-time version
index 629c15a..874edb6 100644 (file)
@@ -16,9 +16,6 @@
 
 #include <folly/ssl/OpenSSLCertUtils.h>
 
-#include <openssl/bio.h>
-#include <openssl/evp.h>
-
 #include <folly/Range.h>
 #include <folly/String.h>
 #include <folly/io/async/ssl/OpenSSLPtrTypes.h>