3333
3434import wolfssl
3535from wolfssl ._build_wolfssl import build_wolfssl
36+ from wolfssl ._build_wolfssl import wolfssl_inc_path , wolfssl_lib_path
3637
3738
3839# long_description
4344 long_description = long_description .replace (".. include:: LICENSING.rst\n " ,
4445 licensing_file .read ())
4546
47+ def verify_wolfssl_config ():
48+ # verify wolfSSL library has been configured correctly, so that cffi
49+ # binding work correctly.
50+
51+ # open <wolfssl/options.h> header to parse for #define's
52+ # This will throw a FileNotFoundError if not able to find options.h
53+ optionsHeaderPath = wolfssl_inc_path () + "/wolfssl/options.h"
54+ optionsHeader = open (optionsHeaderPath , 'r' )
55+ optionsHeaderStr = optionsHeader .read ()
56+ optionsHeader .close ()
57+
58+ # require HAVE_SNI (--enable-sni) in native lib
59+ if '#define HAVE_SNI' not in optionsHeaderStr :
60+ raise RuntimeError ("wolfSSL needs to be compiled with --enable-sni" )
61+
62+ # require OPENSSL_EXTRA (--enable-opensslextra) in native lib
63+ if '#define OPENSSL_EXTRA' not in optionsHeaderStr :
64+ raise RuntimeError ("wolfSSL needs to be compiled with "
65+ "--enable-opensslextra" )
66+
4667class cffiBuilder (build_ext , object ):
4768
4869 def build_extension (self , ext ):
@@ -54,6 +75,8 @@ def build_extension(self, ext):
5475 if os .environ .get ("USE_LOCAL_WOLFSSL" ) is None :
5576 build_wolfssl (wolfssl .__wolfssl_version__ )
5677
78+ verify_wolfssl_config ()
79+
5780 super (cffiBuilder , self ).build_extension (ext )
5881
5982setup (
0 commit comments