Bug 1449163 - tls.hpp, SSL_R_SHORT_READ undefined in openssl-1.1
Summary: tls.hpp, SSL_R_SHORT_READ undefined in openssl-1.1
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: websocketpp
Version: rawhide
Hardware: Unspecified
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Fabian Affolter
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 1440704
TreeView+ depends on / blocked
 
Reported: 2017-05-09 10:49 UTC by c72578
Modified: 2017-06-13 20:25 UTC (History)
4 users (show)

Fixed In Version: websocketpp-0.7.0-5.fc26
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-06-09 19:01:45 UTC
Type: Bug


Attachments (Terms of Use)
Patch to fix SSL_R_SHORT_READ undefined in openssl-1.1 (1.18 KB, patch)
2017-05-09 19:36 UTC, c72578
no flags Details | Diff
Patch to fix SSL_R_SHORT_READ undefined in openssl-1.1 (1.09 KB, patch)
2017-06-13 20:25 UTC, c72578
no flags Details | Diff

Description c72578 2017-05-09 10:49:39 UTC
Description of problem:
SSL_R_SHORT_READ undefined in openssl-1.1.
websocketpp is used as a requirement for building cpprest and during building errors as described below occur.
A suggestion for a patch is found under additional info

Version-Release number of selected component (if applicable):
websocketpp 0.7.0-3

How reproducible:
Always

Steps to Reproduce:
1. Build cpprestsdk for F26 or rawhide
2. Get cpprest source from here:
https://github.com/Microsoft/cpprestsdk
3. Fedora copr builds of cpprest are here:
https://copr.fedorainfracloud.org/coprs/c72578/cpprest/
4. A SPEC file for building cpprest is saved here:
5. Fedora Review Request for cpprest:
https://bugzilla.redhat.com/show_bug.cgi?id=1440704

Actual results:

Error:
/usr/include/websocketpp/transport/asio/security/tls.hpp:358:47: error: 'SSL_R_SHORT_READ' was not declared in this scope
             if (ERR_GET_REASON(ec.value()) == SSL_R_SHORT_READ) {
                                               ^~~~~~~~~~~~~~~~
/usr/include/websocketpp/transport/asio/security/tls.hpp:358:47: note: suggested alternative: 'SSL_F_SSL_READ'
             if (ERR_GET_REASON(ec.value()) == SSL_R_SHORT_READ) {
                                               ^~~~~~~~~~~~~~~~
                                               SSL_F_SSL_READ

Expected results:
No error

Additional info:
SSL_R_SHORT_READ undefined in openssl-1.1
https://github.com/Microsoft/cpprestsdk/pull/285
A suggestion for a patch is found there.

Comment 1 Rex Dieter 2017-05-09 13:47:06 UTC
websocketspp has no such calls, I think you meant to file this against libwebsockets instead

Comment 2 c72578 2017-05-09 19:32:31 UTC
The affected file tls.hpp is part of the package websocketpp-devel.
e.g.:
dnf repoquery -l websocketpp-devel | grep security/tls.hpp
/usr/include/websocketpp/transport/asio/security/tls.hpp

Here is the correct link for the reported upstream websocketpp issue:
https://github.com/zaphoyd/websocketpp/issues/599

The patch file, which is supposed to fix the issue of tls.hpp in Fedora >=26 will be attached here too.

PS: The above link under "Additional info:" was the wrong one - sorry.

Comment 3 c72578 2017-05-09 19:36:40 UTC
Created attachment 1277427 [details]
Patch to fix SSL_R_SHORT_READ undefined in openssl-1.1

Patch from https://github.com/zaphoyd/websocketpp/issues/599
PR: https://github.com/zaphoyd/websocketpp/pull/600

Comment 4 c72578 2017-05-12 09:59:19 UTC
websocketpp test packages, which include the suggested patch, have been created using Fedora copr for F26 and rawhide:
https://copr.fedorainfracloud.org/coprs/c72578/websocketpp/

Spec URL: https://raw.githubusercontent.com/c72578/rpmbuild/master/SPECS/websocketpp.spec
SRPM URL: https://copr-be.cloud.fedoraproject.org/results/c72578/websocketpp/fedora-26-x86_64/00551039-websocketpp/websocketpp-0.7.0-4.fc26.src.rpm

* Fri May 12 2017 Wolfgang Stöggl <c72578@yahoo.de> - 0.7.0-4
- Added websocketpp-Fix-issue-599.patch
  Fixes compilation errors in F26 etc., which contain openssl >= 1.1
  SSL_R_SHORT_READ undefined in openssl-1.1

Comment 5 c72578 2017-05-17 09:53:14 UTC
Here is a simpler/different procedure to reproduce this issue with tls.hpp from websocketpp 0.7.0:

Steps to Reproduce:
1. Carry out the following steps under Fedora 26, which includes openssl 1.1.0e
2. Make sure, that the following packages are installed
sudo dnf install cmake openssl-devel

2. Get websocketcpp source from here:
e.g. websocket-0.7.0 from:
https://github.com/zaphoyd/websocketpp/archive/0.7.0.tar.gz
or using git (preferred):
git clone https://github.com/zaphoyd/websocketpp.git
 
3. Carry out the following commands:
cd websocketpp
mkdir build
cd build
cmake .. -DBUILD_EXAMPLES=ON -DBUILD_TESTS=ON
make -j4

4. The error message appears under Fedora 26, which uses the newer openssl 1.1.0e
Remark: The error does not appear, when carrying out above steps under Fedora 25, which has openssl 1.0.2k.

Actual results:

websocketpp/transport/asio/security/tls.hpp:358:47: error: 'SSL_R_SHORT_READ' was not declared in this scope
             if (ERR_GET_REASON(ec.value()) == SSL_R_SHORT_READ) {
                                               ^~~~~~~~~~~~~~~~
Expected results:
No error

Additional info:
SSL_R_SHORT_READ undefined in openssl-1.1
https://github.com/zaphoyd/websocketpp/issues/599
A suggestion for a patch is found there and attached to this bug report.

websocketpp test packages, which include the suggested patch, have been created using Fedora copr for F26 and rawhide:
https://copr.fedorainfracloud.org/coprs/c72578/websocketpp/

Spec URL: https://raw.githubusercontent.com/c72578/rpmbuild/master/SPECS/websocketpp.spec
SRPM URL: https://copr-be.cloud.fedoraproject.org/results/c72578/websocketpp/fedora-26-x86_64/00551039-websocketpp/websocketpp-0.7.0-4.fc26.src.rpm

Comment 6 Rex Dieter 2017-05-17 15:00:10 UTC
Sorry, my grepping in my original comment was insufficient, but I am a little surprised since websocketpp packaging currently has no direct dependencies on openssl

Comment 7 Rex Dieter 2017-05-17 15:05:07 UTC
nor do we build examples or tests

Comment 8 Rex Dieter 2017-05-17 15:08:19 UTC
but I suppose this error may get caught at buildtime if we did build tests, I'll look into it.

Comment 9 c72578 2017-05-17 16:23:27 UTC
The initial case, where the error turned up, was when trying to build C++ REST SDK under Fedora 26 or rawhide. This package depends on websocketpp-devel and openssl-devel (see review request at https://bugzilla.redhat.com/show_bug.cgi?id=1440704).

The unit tests of websocketpp itself seemed to be the simpler way to test and reproduce the 'SSL_R_SHORT_READ' error here.

Comment 10 Fedora Update System 2017-05-18 13:13:51 UTC
websocketpp-0.7.0-4.fc26 has been submitted as an update to Fedora 26. https://bodhi.fedoraproject.org/updates/FEDORA-2017-39d3695b69

Comment 11 Fedora Update System 2017-05-18 19:05:05 UTC
websocketpp-0.7.0-4.fc26 has been pushed to the Fedora 26 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2017-39d3695b69

Comment 12 c72578 2017-05-22 08:57:23 UTC
In the test package websocketpp-0.7.0-4.fc26, the following is missing in the spec file:
BuildRequires:  openssl-devel

Reason: openssl support of websocketpp is be required from my side.

See the related build log, which shows, that OPENSSL is missing:
https://kojipkgs.fedoraproject.org//packages/websocketpp/0.7.0/4.fc26/data/logs/noarch/build.log

-- OPENSSL_FOUND        = FALSE
-- OPENSSL_INCLUDE_DIR     = OPENSSL_INCLUDE_DIR-NOTFOUND
-- OPENSSL_LIBRARIES = OPENSSL_SSL_LIBRARY-NOTFOUND;OPENSSL_CRYPTO_LIBRARY-NOTFOUND
-- OPENSSL_VERSION =

Comment 13 c72578 2017-05-22 09:20:58 UTC
And when building websocketpp-0.7.0-4.fc26 with openssl-devel the following error occurs now (coming from websocketpp-0.7.0-openssl11.patch) instead of the previous one:

/builddir/build/BUILD/websocketpp-0.7.0/test/transport/asio/security.cpp:65:6:   required from here
/builddir/build/BUILD/websocketpp-0.7.0/websocketpp/transport/asio/security/tls.hpp:363:39: error: could not convert 'boost::asio::ssl::error::make_error_code((boost::asio::ssl::error::stream_errors)1)' from 'boost::system::error_code' to 'std::error_code'
                 return make_error_code(boost::asio::ssl::error::stream_truncated);
                        ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Comment 14 Rex Dieter 2017-05-22 12:49:09 UTC
It's simply now an invalid test, that probably should be fixed too.  Is your dependant software/package affected too?

Comment 15 c72578 2017-05-22 13:31:02 UTC
Yes, the dependent package cpprest is affected in the same way.

FWIW: C++11 and Boost both have an error_code class, but they cannot be used interchangeably despite their close resemblance:
http://breese.github.io/2016/06/18/unifying-error-codes.html

However, it works with the patch, which is attached to this bug report. The attached patch simply removes the "if (ERR_GET_REASON(ec.value()) == SSL_R_SHORT_READ)"... and does not add

"if (ERR_GET_REASON(ec.value()) == boost::asio::ssl::error::stream_truncated) {
    return make_error_code(boost::asio::ssl::error::stream_truncated);"

which does not work because of the differences between boost and std error code.

Comment 16 Rex Dieter 2017-05-22 13:34:35 UTC
OK.  FYI, the patch attached to this report is IMO unacceptable too, since it changes behavior for when using openssl < 1.1

But I can adjust it to be conditional whether SSL_R_SHORT_READ is defined or not.

(Would be nice if websocketpp upstream would agree on a proper fix too, instead of having to guess)

Comment 17 c72578 2017-05-22 13:37:16 UTC
I agree with adjusting it conditional for now as a workaround.
Later on an upstream fix should be the solution.

Comment 18 Fedora Update System 2017-05-22 17:40:10 UTC
websocketpp-0.7.0-5.fc26 has been submitted as an update to Fedora 26. https://bodhi.fedoraproject.org/updates/FEDORA-2017-39d3695b69

Comment 19 Fedora Update System 2017-05-23 18:14:45 UTC
websocketpp-0.7.0-5.fc26 has been pushed to the Fedora 26 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2017-39d3695b69

Comment 20 Fedora Update System 2017-06-09 19:01:45 UTC
websocketpp-0.7.0-5.fc26 has been pushed to the Fedora 26 stable repository. If problems still persist, please make note of it in this bug report.

Comment 21 c72578 2017-06-13 20:25:58 UTC
Created attachment 1287445 [details]
Patch to fix SSL_R_SHORT_READ undefined in openssl-1.1

Finally used version of the patch in websocketpp-0.7.0-5.fc26.
Adjusted to be conditional whether SSL_R_SHORT_READ is defined or not.


Note You need to log in before you can comment on or make changes to this bug.