support defining which windows libraries to link with an env var (#3356)

* support defining which windows libraries to link with an env var

CRYPTOGRAPHY_WINDOWS_LIBRARIES is your new friend

* add some docs

* change to CRYPTOGRAPHY_WINDOWS_LINK_OPENSSL110

* lib prefixing is not a thing msvc does, right
diff --git a/docs/installation.rst b/docs/installation.rst
index 2c24d35..a1b5642 100644
--- a/docs/installation.rst
+++ b/docs/installation.rst
@@ -50,7 +50,7 @@
 You can compile OpenSSL yourself as well or use the binaries we build for our
 release infrastructure (`openssl-release`_). Be sure to download the proper
 version for your architecture and Python (2010 works for Python 2.6, 2.7, 3.3,
-and 3.4 while 2015 is required for 3.5). Wherever you place your copy
+and 3.4 while 2015 is required for 3.5 and above). Wherever you place your copy
 of OpenSSL you'll need to set the ``LIB`` and ``INCLUDE`` environment variables
 to include the proper locations. For example:
 
@@ -59,8 +59,14 @@
     C:\> \path\to\vcvarsall.bat x86_amd64
     C:\> set LIB=C:\OpenSSL-win64\lib;%LIB%
     C:\> set INCLUDE=C:\OpenSSL-win64\include;%INCLUDE%
+    C:\> set CRYPTOGRAPHY_WINDOWS_LINK_OPENSSL110=1
     C:\> pip install cryptography
 
+As of OpenSSL 1.1.0 the library names have changed from ``libeay32`` and
+``ssleay32`` to ``libcrypto`` and ``libssl`` (matching their names on all other
+platforms). Due to this change when linking against 1.1.0 you **must** set
+``CRYPTOGRAPHY_WINDOWS_LINK_OPENSSL110`` or else installation will fail.
+
 If you need to rebuild ``cryptography`` for any reason be sure to clear the
 local `wheel cache`_.
 
diff --git a/src/_cffi_src/build_openssl.py b/src/_cffi_src/build_openssl.py
index 416e1b3..4d2d2c6 100644
--- a/src/_cffi_src/build_openssl.py
+++ b/src/_cffi_src/build_openssl.py
@@ -19,9 +19,18 @@
             os.environ.get("CRYPTOGRAPHY_OSX_NO_LINK_FLAGS")
         )
     elif platform == "win32":
+        windows_link_openssl110 = os.environ.get(
+            "CRYPTOGRAPHY_WINDOWS_LINK_OPENSSL110", None
+        )
         if compiler_type() == "msvc":
-            libs = ["libeay32", "ssleay32"]
+            if windows_link_openssl110 is not None:
+                # Link against the 1.1.0 names
+                libs = ["libssl", "libcrypto"]
+            else:
+                # Link against the 1.0.2 and lower names
+                libs = ["libeay32", "ssleay32"]
         else:
+            # Support mingw, which behaves unix-like and prefixes "lib"
             libs = ["ssl", "crypto"]
         return libs + ["advapi32", "crypt32", "gdi32", "user32", "ws2_32"]
     else: