diff --git a/ChangeLog b/ChangeLog
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2018-01-24  Vladimir Shabanov  <vshabanoff@gmail.com>
+
+	* HsOpenSSL.cabal (Version): Bump version to 0.11.4.12
+
+	* Fix the build with GHC 8.4
+	by Ryan Scott @RyanGlScott (#35)
+
 2017-08-14  Vladimir Shabanov  <vshabanoff@gmail.com>
 
 	* HsOpenSSL.cabal (Version): Bump version to 0.11.4.11
diff --git a/HsOpenSSL.cabal b/HsOpenSSL.cabal
--- a/HsOpenSSL.cabal
+++ b/HsOpenSSL.cabal
@@ -12,7 +12,7 @@
     <http://hackage.haskell.org/package/tls>, which is a pure Haskell
     implementation of SSL.
     .
-Version:       0.11.4.11
+Version:       0.11.4.12
 License:       PublicDomain
 License-File:  COPYING
 Author:        Adam Langley, Mikhail Vorozhtsov, PHO, Taru Karttunen
diff --git a/Setup.hs b/Setup.hs
--- a/Setup.hs
+++ b/Setup.hs
@@ -18,6 +18,12 @@
 import Distribution.PackageDescription (FlagName(..))
 #endif
 
+#if MIN_VERSION_Cabal(2,1,0)
+import Distribution.PackageDescription (mkFlagAssignment, unFlagAssignment)
+#else
+import Distribution.PackageDescription (FlagAssignment)
+#endif
+
 import Distribution.Verbosity (silent)
 import System.Info (os)
 import qualified Control.Exception as E (tryJust, throw)
@@ -29,6 +35,14 @@
 mkFlagName = FlagName
 #endif
 
+#if !(MIN_VERSION_Cabal(2,1,0))
+mkFlagAssignment :: [(FlagName, Bool)] -> FlagAssignment
+mkFlagAssignment = id
+
+unFlagAssignment :: FlagAssignment -> [(FlagName, Bool)]
+unFlagAssignment = id
+#endif
+
 -- On macOS we're checking whether OpenSSL library is avaiable
 -- and if not, we're trying to find Homebrew or MacPorts OpenSSL installations.
 --
@@ -51,7 +65,7 @@
     case c of
         Right lbi -> return lbi -- library was found
         Left e
-            | configConfigurationsFlags cfg
+            | unFlagAssignment (configConfigurationsFlags cfg)
               `intersect` [(mkFlagName f, True) | f <- flags] /= [] ->
                 E.throw e
                 -- flag was set but library still wasn't found
@@ -86,7 +100,10 @@
     , "to specify location of installed OpenSSL library."
     ]
 
-setFlag f c = c { configConfigurationsFlags = go (configConfigurationsFlags c) }
+setFlag f c = c { configConfigurationsFlags = mkFlagAssignment
+                                            $ go
+                                            $ unFlagAssignment
+                                            $ configConfigurationsFlags c }
     where go [] = []
           go (x@(n, _):xs)
               | n == f = (f, True) : xs
