This repository was archived by the owner on Jan 8, 2020. It is now read-only.
SSL CA File support.#5870
Merged
Merged
Conversation
Member
|
Please add tests |
Contributor
Author
|
Added tests, and valid ca-bundle.crt file to minimize changes. As there are no tests existing that test the "sslcapath" option; I just went with something that just tests that the context option was set on connect based on As this is may be highly system-dependent, it's hard to say whether the certificate file will parse correctly and set the context option across multiple environments (ie: Windows) |
Contributor
|
@icywolfy thanks for this PR, I think make perfectly sense to support the CA file for SSL. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Environment
Centos 6; presumably others.
Problem
Using the default Socket client adapter doesn't work.
People give up in trying to get the SSL Certificates working, and thus
set ssl_verify_peer = falseto get it working.The advice "Set the
ssl_ca_pathoption" doesn't work, and errors.For example, By using a the
/etc/ssl/certsdirectory here (or it's resolved location of/etc/pki/tls/certs, you end up with the Socket adapter giving the error:"error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed"This is an issue repeated many times on the internet, and I've run into it personally often (and admittedly, had just disabled verify_peer for a while to get development working)
Background
The underlying issue is that these systems are incompatible with the ssl stream context options
capath. In that the directory contains a certificate bundle file and not (as the PHP manual states) a "correctly hashed certificate directory"Where according to the OpenSSL documentation, the direcotry must contain files in the form
hash.0wherehashis the hashed certificate subject name.Solution
OpenSSL Documentation states that the cafile option contains "A file of trusted certificates. The file should contain multiple certificates in PEM format concatenated together."
And thus the correct answer is to set the context option
cafileto'/etc/ssl/certs/ca-bundle.crt'on these systems. (I have seen on some client systems the filename beingcertificate-bundle.crt, so it will be highly environment specific)If you set an non existant file, and have openssl_error_string, the result will be :
Workaround For < 2.2.5*
Currently, for the Socket Adapter to work one needs to have a factory to manually make use of the cafile; rather than pass in the configuration array verbatim.