Skip to content

PHPC-605: Rely on libmongoc for socket handling and TLS #361

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

Merged
merged 7 commits into from
Aug 30, 2016

Conversation

jmikola
Copy link
Member

@jmikola jmikola commented Jul 29, 2016

}

if (php_array_existsc(sslOptions, "capath")) {
ssl_opt.ca_dir = php_array_fetchc_string(sslOptions, "capath", &plen, &free_ca_dir);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: When using the Native Darwin or Windows TLS libraries, this will result in an MONGOC_EROR() when used.

That might only be problem if you start falling back on the openssl.capath php.ini settings, but though I'd call it out

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I correct in assuming that only different here is customizing the entire CA path? All three will allow a custom CA file, which I suppose most users can stick to if they have a special cert.

Would the default CA path for each generally be sufficient? Since we won't be using PHP's OpenSSL extension at all, I'm on the fence about whether we should even default to openssl.capath.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is correct. Most people using their own authority would be providing that cert/bundle as cafile or include it in the OS default chain, and not provide anything.

The only reason we are supporting capath is because why not? -- which then turned into err, we shouldn't have.

}

if (php_array_existsc(zoptions, "verify_hostname")) {
ssl_opt.allow_invalid_hostname = !php_array_fetchc_bool(zoptions, "verify_hostname");
Copy link
Member Author

@jmikola jmikola Aug 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@derickr: HHVM doesn't appear to support this at all.

Also, PHP's own SSL context options don't have anything called verify_hostname, so I propose we just name our option allow_invalid_hostname. We should probably continue to support the undocumented verify_hostname option for BC.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't find any record of verify_hostname being used in the old code or PHP core. It's not a documented SSL context option. Perhaps we should just remove it entirely and stick with allow_invalid_hostname.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See: https://jira.mongodb.org/browse/PHPC-192?focusedCommentId=861601&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-861601

Looks like I was planning on ditching this approach, in favor of custom mortal people readble options instead.
Doesn't look like that materialized, but the accidental NOOP context option remained in the code

@bjori
Copy link
Contributor

bjori commented Aug 25, 2016

this lgtm. so much removed code \o/

@jmikola jmikola changed the title [WIP] PHPC-605: Rely on libmongoc for socket handling and TLS PHPC-605: Rely on libmongoc for socket handling and TLS Aug 29, 2016
@jmikola jmikola force-pushed the phpc-605 branch 2 times, most recently from d0d1636 to f9c9601 Compare August 29, 2016 18:46
@jmikola
Copy link
Member Author

jmikola commented Aug 29, 2016

@derickr: Ready for a final review.

}
}

/* Check canonical option names first and fall back to SSL context options
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will need to do the same - are you tests covering all of this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not bother using both options (canonical and alias) in a single test. All of the tests are just split for using a $driverOptions array with canonical options and a stream context with the BC aliases.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@derickr
Copy link
Contributor

derickr commented Aug 30, 2016

Looks mostly good - I had a few comments though.

This option is not supported by libmongoc's SSL implementation.

The test for PHPC-720 can be modified to allow invalid host names.
This test overlaps with the standalone-ssl-no_verify tests, which are already testing SSL connections with no host and cert verification.
Expected output changes now that PHP streams are no longer used for socket IO.
@jmikola jmikola merged commit ae6016e into mongodb:master Aug 30, 2016
jmikola added a commit that referenced this pull request Aug 30, 2016
@jmikola jmikola deleted the phpc-605 branch August 30, 2016 19:05
'ca_file' => $SSL_DIR . '/ca.pem',
'pem_file' => $SSL_DIR . '/client.pem',
// TODO: this doesn't appear to have any effect. Does the PEM file not have a password?
'pem_pwd' => 'qwerty',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot to remove this before merging. Will be addressed in #376.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants