-
Notifications
You must be signed in to change notification settings - Fork 208
PHPC-888: Support additional TLS libraries for bundled libmongoc #736
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
Conversation
fdd3f3e
to
1017c75
Compare
scripts/build/autotools/CheckSSL.m4
Outdated
found_libressl="no" | ||
|
||
dnl TODO: this may require adding libcrypto to the modules list, as pkg-config does not seem to include it (unlike openssl) | ||
PKG_CHECK_MODULES([PHP_MONGODB_SSL],[libtls],[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: when testing this on my Ubuntu system, I actually had to change "libtls" to "libressl-tls" (since I'm using a custom PPA). I also noticed that pkg-config --libs libressl-tls
returns only -lressl-tls
, unlike pkg-config --libs openssl
, which returns -lssl -lcrypto
. I'm not sure if that's specific to the PPA package I'm using, so I'll have to test with LibreSSL proper.
FWIW, libmongoc also only specifics "libtls", so I'm curious if their LibreSSL builds are linking -lcrypto
or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's possible that your PPA doesn't need the -lcrypto, and just that -lressl-tls contains all of what -lssl and -lcrypt export. I would actually go as far to make sure that we can support your custom PPA, and the normal libressl.
@@ -83,7 +79,7 @@ AC_DEFUN([PHP_BSON_CLOCK], | |||
fi | |||
]) | |||
|
|||
if test "$MONGODB" != "no"; then | |||
if test "$PHP_MONGODB" != "no"; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh - this must never have worked then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No sir, it did not :)
scripts/build/autotools/CheckHost.m4
Outdated
;; | ||
*-*-*netbsd*) | ||
os_netbsd=yes | ||
TARGET_OS=unix |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some whitespace issues in this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the TARGET_OS
assignments all used tab indents. Fixing now.
scripts/build/autotools/CheckSSL.m4
Outdated
PHP_ARG_WITH([mongodb-ssl], | ||
[whether to enable crypto and TLS], | ||
[AS_HELP_STRING([--with-mongodb-ssl=@<:@auto/no/openssl/libressl/darwin@:>@], | ||
[Enable TLS connections and SCRAM-SHA-1 authentication [default=auto]])], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think all the help options, should be prefixed with " MongoDB: ", just as I currently do at https://github.com/xdebug/xdebug/blob/master/config.m4#L7
AC_CHECK_DECLS([ASN1_STRING_get0_data], | ||
[have_ASN1_STRING_get0_data="yes"], | ||
[have_ASN1_STRING_get0_data="no"], | ||
[[#include <openssl/asn1.h>]]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are there two sets of [ ] here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quoting https://lists.gnu.org/archive/html/bug-gnulib/2011-09/msg00172.html:
#
is a comment character in m4, which reads until end-of-line to end the comment. Which means all the[]
after the comment character are treated as part of the comment, instead of as m4[]
quoting.
https://lists.gnu.org/archive/html/bug-gnulib/2011-09/msg00193.html discusses modifying AC_CHECK_DECLS
to double-quote.
Note that we also used double-quoting in the original check in config.m4
.
scripts/build/autotools/CheckSSL.m4
Outdated
found_openssl="no" | ||
|
||
PKG_CHECK_MODULES([PHP_MONGODB_SSL],[openssl],[ | ||
dnl PKG_CHECK_MODULES() doesn't check for headers, so confirm they exist (mainly for macOS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems odd. The whole idea behind pkg_config is that its --includes (or whatever the flag is), shows all the header locations. I don't think we should go check all the headers manually where pkg-config works.
scripts/build/autotools/CheckSSL.m4
Outdated
found_libressl="no" | ||
|
||
dnl TODO: this may require adding libcrypto to the modules list, as pkg-config does not seem to include it (unlike openssl) | ||
PKG_CHECK_MODULES([PHP_MONGODB_SSL],[libtls],[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's possible that your PPA doesn't need the -lcrypto, and just that -lressl-tls contains all of what -lssl and -lcrypt export. I would actually go as far to make sure that we can support your custom PPA, and the normal libressl.
|
||
dnl Disable Windows SSL and crypto | ||
AC_SUBST(MONGOC_ENABLE_SSL_SECURE_CHANNEL, 0) | ||
AC_SUBST(MONGOC_ENABLE_CRYPTO_CNG, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the idea to support these later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe so, since Windows builds use config.w32
and will never use Autotools. We do still need to make the substitutions, though.
scripts/build/autotools/CheckSSL.m4
Outdated
|
||
CFLAGS="$old_CFLAGS" | ||
else | ||
AC_SUBST(MONGOC_HAVE_ASN1_STRING_GET0_DATA, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You've already done the ASN1_STRING_get0_data check earlier. Do you need it twice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe I forgot to remove this if/else block from the file. The problem with this is that CFLAGS
may change depending on whether we found OpenSSL with pkg-config
(sets PHP_MONGODB_SSL_CFLAGS
) or manual header searching and PHP_CHECK_LIBRARY
(sets OPENSSL_INCDIR
).
Therefore, this if/else block should be removed and we should only keep the one below here:
if test "x$have_ASN1_STRING_get0_data" = "xyes"; then
AC_SUBST(MONGOC_HAVE_ASN1_STRING_GET0_DATA, 1)
else
AC_SUBST(MONGOC_HAVE_ASN1_STRING_GET0_DATA, 0)
fi
8d3de91
to
4806b57
Compare
@sibidharan: Since you did such a great job solving the BoringSSL issues, I wonder if you'd be willing to help us test this PR on macOS. I plan to add macOS to our Travis CI matrix, but would still appreciate a fresh set of eyes on it. This PR introduces a new |
That is indeed such a great news @jmikola I will test it out on all our peer systems running on couple different versions of MacOS. |
8072f70
to
b1a506a
Compare
@derickr: The last commit adds three macOS environments to the build matrix:
Note that since we only have a standalone I've no idea when these will actually complete, as Travis CI status is reporting degraded performance for macOS builds and their backlog appears to consistently be >1000 jobs. |
.travis.scripts/before_script.sh
Outdated
make install | ||
|
||
# Use latest run-tests.php, as older versions don't report a non-zero exit code for failures | ||
wget -O run-tests.php https://raw.githubusercontent.com/php/php-src/master/run-tests.php |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need to do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I very much remember the problem with run-tests.php
exiting with zero after failures, I don't quite remember what versions of PHP demonstrated the issue. There is evidence of exit(1)
going back to PHP-5.3.
I did come across php/php-src@16efc77, which changed the logic for exit(1)
in 5.5. Do you recall if this was only an issue up to 5.4 (inclusive)?
If you're able to narrow it down, we can certainly get rid of this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll narrow this down in a bit and if 5.5+ reports exit codes, we can remove this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed that PHP 5.4 was the last version with this problem. I'll remove this.
@@ -2,6 +2,7 @@ | |||
Connect to MongoDB with SSL and X509 auth and username retrieved from cert (stream context) | |||
--SKIPIF-- | |||
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?> | |||
<?php NEEDS_SSL(['OpenSSL', 'Secure Transport', 'Secure Channel']); ?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can this not be LibreSSL?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -0,0 +1,199 @@ | |||
# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- | |||
# serial 1 (pkg-config-0.24) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file isn't one you wrote yourself, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. There may be whitespace issues (mixed tabs and spaces) that I can clean up, though. We imported from libmongoc, but they also pulled it from elsewhere.
@@ -502,7 +477,7 @@ if test "$MONGODB" != "no"; then | |||
AC_OUTPUT($srcdir/src/libmongoc/src/zlib-1.2.11/zconf.h) | |||
fi | |||
fi | |||
if test "$PHP_LIBBSON" == "no"; then | |||
if test "$PHP_LIBBSON" = "no"; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this always broken like this before? Or do both = and == work (on bash)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bash supports both ==
and =
, but =
is POSIX compliant. You'll note from the new shell scripts that I'm aiming to keep things portable with #!/bin/sh
and POSIX-friendly syntax.
|
||
before_install: | ||
- sudo pip install --upgrade cpp-coveralls | ||
- sudo pip install ${MONGODB_ORCHESTRATION_REPO} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't see where mongo orchestration is installed through in the new code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See ef72444d5239f43792a942cd9938b89bb4fbde1c. These were merely artifacts from when Hannes was using Mongo Orchestration locally to spin up test environments (PHPC-128). I found nothing in our current .travis.yml
files that actually launched Mongo Orchestration, so this all appears to be dead code.
41a5ef9
to
982de4b
Compare
@derickr: I borrowed a Macbook (macOS 10.12.5) and verified that I'm able to successfully compile the driver for Secure Transport using @sibidharan: If you're still able to test, that'd be appreciated; however, you're not holding us up :) @alcaeus: I expect we'll cut a 1.4.0-RC1 release next week. Would it be possible to update the |
The double equal operator is a Bash-specific alias
Travis' backlog for macOS builds is quite high, and the environments also do not support MongoDB. We can revisit adding these environments down the line when the infrastructure has improved and we sort out explicit installation of MongoDB versions (see: PHPLIB-299). Note: a macOS build with Secure Channel was manually tested in mongodb#736.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made a PR against yours with a few tweaks:
jmikola#2
Besides that, it looks good and things worked as expected on the platforms I've tried it on (various Debians)
fi | ||
]) | ||
|
||
AS_IF([test "$PHP_MONGODB_SSL" = "darwin" -o \( "$PHP_MONGODB_SSL" = "auto" -a "$os_darwin" = "yes" \)],[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something is going wrong here, as I can select "darwin" as option on my Linux system and configure doesn't complain. It will of course fail when trying to compile.
These lines were originally added before 1.0 when a local Mongo Orchestration process was used to create the test environments (see: PHPC-128).
If a directory is excluded, a negation on the files within it (e.g. "!dir/*") has no effect. Since .travis.scripts/ is excluded by ".*", we need to negate the directory itself to ensure the files within are tracked.
This was last updated in 90a64b4 when the project was hosted in the 10gen-labs groups.
PHP 5.4 was the last version where run-tests.php failed to report a non-zero exit code after a failure. Since the extension requires 5.5+, we can rely on any existing run-tests.php file.
Travis' backlog for macOS builds is quite high, and the environments also do not support MongoDB. We can revisit adding these environments down the line when the infrastructure has improved and we sort out explicit installation of MongoDB versions (see: PHPLIB-299). Note: a macOS build with Secure Channel was manually tested in mongodb#736.
This makes for more chronological configure output
This also documents "yes" values for the libbson/libmongoc parameters, and the "auto" default for SASL.
https://jira.mongodb.org/browse/PHPC-888
https://jira.mongodb.org/browse/PHPC-1003