Bug #91010 WolfSSL build broken due to cmake typo
Submitted: 24 May 2018 12:27 Modified: 23 Aug 2018 8:12
Reporter: Laurynas Biveinis (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:8.0.11 OS:Any
Assigned to: CPU Architecture:Any
Tags: cmake, wolfSSL

[24 May 2018 12:27] Laurynas Biveinis
Description:
Attempting a WolfSSL build stops due to a typo.

-- Configuring done
CMake Error at cmake/libutils.cmake:73 (ADD_LIBRARY):
  Cannot find source file:

    ../../client/get_password.c

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
  .hpp .hxx .in .txx
Call Stack (most recent call first):
  extra/wolfssl-3.13.0/CMakeLists.txt:37 (ADD_CONVENIENCE_LIBRARY)

CMake Error at cmake/libutils.cmake:73 (ADD_LIBRARY):
  No SOURCES given to target: wolfssl
Call Stack (most recent call first):
  extra/wolfssl-3.13.0/CMakeLists.txt:37 (ADD_CONVENIENCE_LIBRARY)

How to repeat:
- follow extra/README-wolfssl.txt instructions
- cmake ... -DWITH_SSL=wolfssl

Suggested fix:
extra/wolfssl-3.13.0/CMakeLists.txt contains

SET(WOLFSSL_SOURCES  src/crl.c src/internal.c src/keys.c src/sniffer.c
        src/tls.c src/wolfio.c src/ocsp.c src/ssl.c
                                ../../client/get_password.c )

get_password.c should be get_password.cc instead.

This allows cmake to complete, I have not tested it further yet.
[24 May 2018 13:23] Laurynas Biveinis
It seems that there are further issues past the CMake typo:

[  7%] Building CXX object libmysql/CMakeFiles/clientlib.dir/__/sql-common/client_authentication.cc.o
/Users/laurynas/percona/mysql-server/sql-common/client_authentication.cc:116:24: error: use of undeclared identifier 'PEM_read_RSA_PUBKEY'
  key = g_public_key = PEM_read_RSA_PUBKEY(pub_key_file, 0, 0, 0);
                       ^
/Users/laurynas/percona/mysql-server/sql-common/client_authentication.cc:391:22: error: use of undeclared identifier 'PEM_read_bio_RSA_PUBKEY'
        public_key = PEM_read_bio_RSA_PUBKEY(bio, NULL, NULL, NULL);
                     ^
2 errors generated.
[25 May 2018 15:33] Umesh Shastry
Hello Laurynas,

Thank you for the report.

Thanks,
Umesh
[25 May 2018 15:33] Umesh Shastry
Build details

Attachment: 91010.build (application/octet-stream, text), 23.04 KiB.

[28 May 2018 10:37] Georgi Kodinov
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://dev.mysql.com/doc/ and the instructions on
how to report a bug at http://bugs.mysql.com/how-to-report.php

https://dev.mysql.com/doc/refman/8.0/en/building-with-encrypted-connection-support.html says:
"
To compile using wolfSSL, download the wolfSSL distribution and apply a small patch. For instructions, see the extra/README-wolfssl.txt file. 
"
[28 May 2018 10:40] Laurynas Biveinis
To the best of my understanding, I have followed README-wolfssl.txt instructions precisely.
[30 May 2018 6:52] Georgi Kodinov
Then you may have noticed the item about applying a diff to wolfSSL ?
This is the diff: https://github.com/gkodinov/wolfssl-diff-for-mysql-8.0/blob/master/wolfssl-3.14.0-mysql.di...

And it does have the following fragment in it:

diff -ur -N -d -x CMakeLists.txt wolfssl-3.14.0-pristine/IDE/MYSQL/CMakeLists_wolfSSL.txt wolfssl-3.14.0/IDE/MYSQL/CMakeLists_wolfSSL.txt
--- wolfssl-3.14.0-pristine/IDE/MYSQL/CMakeLists_wolfSSL.txt	2018-03-02 23:38:23.000000000 +0200
+++ wolfssl-3.14.0/IDE/MYSQL/CMakeLists_wolfSSL.txt	2018-03-07 10:47:54.077997300 +0200
@@ -32,7 +32,7 @@

 SET(WOLFSSL_SOURCES  src/crl.c src/internal.c src/keys.c src/sniffer.c
         src/tls.c src/wolfio.c src/ocsp.c src/ssl.c
-                                ../../client/get_password.c )
+                                ../../client/get_password.cc )
[30 May 2018 7:22] Laurynas Biveinis
I have not noticed a bit about diff because I don't see it there. Here's the entire READM-wolfssl.txt, minus the GPL header: (https://github.com/mysql/mysql-server/blob/8.0/extra/README-wolfssl.txt)

----
Instructions on how to compile with wolfssl

* Get wolfssl-3.13.0.zip from wolfssl.com
* Extract it to extra/wolfssl-3.13.0
* cd extra/wolfssl-3.13.0/IDE/MYSQL
* Execute do.sh
* use -DWITH_SSL=wolfssl for CMake
---

Nowhere it mentions any patches (the do.sh script does not patch neither - it copies CMakeLists.txt around)
[30 May 2018 7:30] Shane Bester
when i tried it a while ago it also was not clear... (dev-private list, subject 'yaSSL is gone')
[30 May 2018 11:02] Frederic Descamps
The change didn't reach the tree yet. Here is the modified version of that readme file:

* Get wolfssl-3.14.0.zip from wolfssl.com
* Extract it to extra/wolfssl-3.14.0
* Download wolfssl-3.14.0-mysql.diff to extra/wolfssl-3.14.0 folder from:
  https://github.com/gkodinov/wolfssl-diff-for-mysql-8.0
* Apply wolfssl-3.14.0-mysql.diff:
  cd extra/wolfssl-3.14.0
  patch -p1 < wolfssl-3.14.0-mysql.diff
* cd extra/wolfssl-3.14.0/IDE/MYSQL
* Execute do.sh
* use -DWITH_SSL=wolfssl for CMake
[11 Jun 2018 8:22] Umesh Shastry
Hello Laurynas, Frederic,

Thank you Frederic for confirming that fix didn't reach the tree yet.
For now closing this report but please feel free to reopen again if the issue persist.

Regards,
Umesh
[13 Jun 2018 9:11] Laurynas Biveinis
Trying with the right instructions.

1) They need a minor update in that there is no wolfssl-3.14.0.zip at wolfssl.com - only 3.15.0 and 3.13.0. I am trying with wolfssl-3.14.0-stable.zip from https://github.com/wolfSSL/wolfssl/releases

2) I still get build errors on a minimally patched source tree:

/Users/laurynas/percona/mysql-server/sql-common/client_authentication.cc:116:24: error: use of undeclared identifier 'PEM_read_RSA_PUBKEY'
  key = g_public_key = PEM_read_RSA_PUBKEY(pub_key_file, 0, 0, 0);
                       ^
/Users/laurynas/percona/mysql-server/sql-common/client_authentication.cc:391:22: error: use of undeclared identifier 'PEM_read_bio_RSA_PUBKEY'
        public_key = PEM_read_bio_RSA_PUBKEY(bio, NULL, NULL, NULL);
                     ^
2 errors generated.
make[2]: *** [libmysql/CMakeFiles/clientlib.dir/__/sql-common/client_authentication.cc.o] Error 1

I will retry with a clean tree now.
[13 Jun 2018 11:27] Laurynas Biveinis
On a clean tree it fails at CMake, because the instructions use 3.14.0 whereas cmake/ssl.cmake has SET(WOLFSSL_VERSION "3.13.0"), resulting in

-- WOLFSSL_SOURCE_DIR = /Users/laurynas/percona/mysql-8.0.11/extra/wolfssl-3.13.0
CMake Error at cmake/ssl.cmake:100 (ADD_SUBDIRECTORY):
  ADD_SUBDIRECTORY given source
  "/Users/laurynas/percona/mysql-8.0.11/extra/wolfssl-3.13.0" which is not an
  existing directory.
Call Stack (most recent call first):
  cmake/ssl.cmake:157 (MYSQL_USE_WOLFSSL)
  CMakeLists.txt:764 (MYSQL_CHECK_SSL)
[14 Jun 2018 7:30] Umesh Shastry
Thank you,Laurynas.
I followed Frederic's steps but seeing the issue as Laurynas reported.
Reverting status back to "Verified".

Regards,
Umesh
[14 Jun 2018 7:30] Umesh Shastry
Build details

Attachment: 91010_patched.build (application/octet-stream, text), 24.19 KiB.

[23 Aug 2018 7:51] Georgi Kodinov
Posted by developer:
 
It should be fixed now with 8.0.12 out, wolf-3.14.0 and the lasted diff on github. Can you please double-check ?
[23 Aug 2018 8:12] Laurynas Biveinis
It is in my plans to test, but might be a few days before I get to it