Fix build on OS X
Fix error checking for SNI