Skip to content

Instantly share code, notes, and snippets.

@shi-yan
Last active September 18, 2018 00:02
Show Gist options
  • Save shi-yan/dc97d0c89db1b791e03a96d81e9ac29f to your computer and use it in GitHub Desktop.
Save shi-yan/dc97d0c89db1b791e03a96d81e9ac29f to your computer and use it in GitHub Desktop.
How to solve node-odbc + Microsoft ODBC driver issue [error:140A90A1:SSL routines:SSL_CTX_new:library has no ciphers]
{ [Error: [unixODBC][Microsoft][ODBC Driver 17 for SQL Server]SSL Provider: [error:140A90A1:SSL routines:SSL_CTX_new:library has no ciphers]]
  errors:
   [ { message:
        '[unixODBC][Microsoft][ODBC Driver 17 for SQL Server]SSL Provider: [error:140A90A1:SSL routines:SSL_CTX_new:library has no ciphers]',
       state: '08001' },
     { message:
        '[unixODBC][Microsoft][ODBC Driver 17 for SQL Server]Client unable to establish connection',
       state: '08001' } ],
  error: '[node-odbc] SQL_ERROR',
  message:
   '[unixODBC][Microsoft][ODBC Driver 17 for SQL Server]SSL Provider: [error:140A90A1:SSL routines:SSL_CTX_new:library has no ciphers]',
  state: '08001' }

The above is the original error message using node 10.10 + node-odbc + unixodbc + Microsoft's odbc driver 17.

MS odbc 17 uses openssl 1.0.2, but node 10.10 initiaizes Openssl incorrectly. With gdb, you could see, node calls OPENSSL_init_ssl

#0  0x000000000132b1d4 in ssl_load_ciphers ()
#1  0x000000000132eebe in ossl_init_ssl_base_ossl_ ()
#2  0x00007ffff6e75827 in __pthread_once_slow (once_control=0x2489d58 <ssl_base>, init_routine=0x132ed00 <ossl_init_ssl_base_ossl_>) at pthread_once.c:116
#3  0x00000000014613e9 in CRYPTO_THREAD_run_once ()
#4  0x000000000132ef9f in OPENSSL_init_ssl ()
#5  0x00000000009f4fc0 in node::crypto::InitCryptoOnce() ()
#6  0x00007ffff6e75827 in __pthread_once_slow (once_control=0x24789c0 <node::crypto::Initialize(v8::Local<v8::Object>, v8::Local<v8::Value>, v8::Local<v8::Context>, void*)::init_once>, 
    init_routine=0x9f4fb0 <node::crypto::InitCryptoOnce()>) at pthread_once.c:116
#7  0x00007ffff6e758e5 in __GI___pthread_once (once_control=<optimized out>, init_routine=<optimized out>) at pthread_once.c:143
#8  0x0000000000a39e79 in uv_once (guard=<optimized out>, callback=<optimized out>) at ../deps/uv/src/unix/thread.c:363
#9  0x00000000009fb7bc in node::crypto::Initialize(v8::Local<v8::Object>, v8::Local<v8::Value>, v8::Local<v8::Context>, void*) ()
#10 0x00000000008d45c3 in node::GetBinding(v8::FunctionCallbackInfo<v8::Value> const&) ()
#11 0x0000000000b8936f in v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) ()
#12 0x0000000000b89ed9 in v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) ()

according to

https://wiki.openssl.org/index.php/Library_Initialization

SSL_library_init should be called instead for openssl <= 1.0.2

downgrading node to 9.11.2 fixed the problem.

https://www.abeautifulsite.net/how-to-upgrade-or-downgrade-nodejs-using-npm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment