-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't connect to Atlas - Error:No suitable servers found #313
Comments
@Jeff-Lewis: Can you substitute your cluster's hostname in the script below, run this through the same PHP environment, and share its output? <?php
$uri = 'ssl://example-shard-00-00-00000.mongodb.net:27017';
$context = stream_context_create(['ssl' => ['capture_peer_cert' => true]]);
$client = stream_socket_client($uri, $errno, $errstr, 1, STREAM_CLIENT_CONNECT, $context);
$response = stream_context_get_params($client);
$certificateProperties = openssl_x509_parse($response['options']['ssl']['peer_certificate']);
var_dump($certificateProperties); |
@jmikola thanks, here it is.
|
@Jeff-Lewis: Can you share |
And a second test would be to attempt certification verification for another hostname with the same certificate authority as Atlas (e.g. MongoDB.com):
Additionally, if you substitute one of the Atlas hosts in the
|
Here's mongodb.com
with strlen of 61522 Here's the php info Also, I do get the |
Based on your Could you attempt capturing some trace information via the mongodb.debug INI option? If you're running in a web server context, you can set this to a writable directory, which will cause the driver to dump one file per request. Alternatively, you can use "stderr" if running the script from a CLI context. These logs are quite verbose, so I would suggest either doing it only for a single request. You can enable the setting at runtime with |
Here is the mongodb.debug output. I had to trim a little to remove connection info. If you need the complete frames, we'll have to go through Mongo support. |
the fallback on the system store failed some reason. |
@Jeff-Lewis: As an temporary workaround, you may be able to get by with providing the path to a CA file explicitly via the With some help from http://stackoverflow.com/a/23554225/162228, it looks like the CA file for "DigiCert SHA2 Secure Server CA" is available on https://www.digicert.com/digicert-root-certificates.htm:
|
@bjori came up with a patch that opens the certificate store with a read-only flag (on the assumption that permissions were a factor here) and also adds more verbose error reporting in the event of a failure: src/mongoc/mongoc-openssl.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/src/mongoc/mongoc-openssl.c b/src/mongoc/mongoc-openssl.c
index 4b3a64f..96e119e 100644
--- a/src/mongoc/mongoc-openssl.c
+++ b/src/mongoc/mongoc-openssl.c
@@ -122,7 +122,20 @@ _mongoc_openssl_import_cert_store (LPWSTR store_name,
store_name); /* system store name. "My" or "Root" */
if (cert_store == NULL) {
- MONGOC_WARNING ("error opening system CA store");
+ LPTSTR msg = NULL;
+ FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_ARGUMENT_ARRAY,
+ NULL,
+ GetLastError (),
+ LANG_NEUTRAL,
+ (LPTSTR) &msg,
+ 0,
+ NULL);
+ MONGOC_ERROR ("Can't open CA store: 0x%.8X: '%s'",
+ GetLastError (),
+ msg);
+ LocalFree (msg);
return false;
}
@@ -158,12 +171,12 @@ _mongoc_openssl_import_cert_stores (SSL_CTX *context)
}
retval = _mongoc_openssl_import_cert_store (
- L"root", CERT_SYSTEM_STORE_CURRENT_USER, store);
+ L"root", CERT_SYSTEM_STORE_CURRENT_USER|CERT_STORE_READONLY_FLAG, store);
if (retval) {
return retval;
}
return _mongoc_openssl_import_cert_store (
- L"CA", CERT_SYSTEM_STORE_CURRENT_USER, store);
+ L"CA", CERT_SYSTEM_STORE_CURRENT_USER|CERT_STORE_READONLY_FLAG, store);
}
#endif @Jeff-Lewis: I compiled this into a custom DLL based on your environment info from |
Yes, your patch appears to work! Thank you @jmikola. Do you need the |
@Jeff-Lewis: If you're didn't encounter an error/exception, there's no need for I've opened CDRIVER-1964 upstream so that @bjori can incorporate his patch into libmongoc. I've also opened PHPC-881 as a local tracking ticket. Since our Windows builds always use bundled versions of libmongoc, this will be formally addressed when libmongoc releases a fix and we can bump our submodules. At that point, PHPC-881 will get a fix version for our subsequent release. I'll close this, since there should be nothing further to address. Please watch the above JIRA tickets for updates. |
#313 bumps our libmongoc dependency, so we should have this fix released in 1.2.3 sometime next week. |
@Jeff-Lewis: 1.2.3 was released yesterday with the fix. You'll find Windows DLLs here. |
@jmikola awesome, thank you! I'll give it a try shortly. |
I'm having trouble connecting to Atlas as well with PHP. Connect fine using other libs and MongoChef so whitelisting is not the issue.
The sanitized url:
Posted as suggested
The text was updated successfully, but these errors were encountered: