View Issue Details

IDProjectCategoryView StatusLast Update
0004917libmicrohttpd2HTTPS (TLS)public2025-12-21 17:41
Reportersilvioprog Assigned ToKarlson2k Due Date
PrioritynormalSeverityfeatureReproducibilityhave not tried
Status resolvedResolutionfixed 
Product VersionGit master 
Target Version1.99.0Fixed in Version1.99.0 
Summary0004917: OpenSSL support
DescriptionHello,

It would be nice to implement OpenSSL support in MHD.

Thank you!
TagsNo tags attached.

Relationships

related to 0006671 new New API support allowing to load the TLS library dynamically. 

Activities

ghaderer

2017-10-13 12:36

reporter   ~0012475

Hello,

I made changes to support OpenSSL and other TLS engines. You will find my working branch here: https://github.com/ghaderer/libmicrohttpd/tree/wip-openssl-master. Could you review it and tell me if this is something you could integrate? If you don't, what should be done to improve it and have it checked in?

I tested on Linux/amd64. All existing tests pass. Not tested on Windows at all.

Cheers,


Gauthier

silvioprog

2018-01-31 23:07

reporter   ~0012847

Hello.

Thanks a lot for implementing and sharing it, I'm going to test your changes as soon as possible.

OpenSSL support is an awesome feature, it requires a detailed test ...

silvioprog

2018-02-01 00:07

reporter   ~0012848

Hello again @ghaderer .

I took a look at your changes, really impressive. However, I've tried to compile it on my Xubuntu and got the following error:

./configure --with-gnutls=no --with-openssl=yes
make

[snip]
gcc -DHAVE_CONFIG_H -I. -I../..  -I../../src/include -DDATA_DIR=\"../../src/datadir/\" -DCPU_COUNT=8    -g -O2 -fno-strict-aliasing -MT benchmark-benchmark.o -MD -MP -MF .deps/benchmark-benchmark.Tpo -c -o benchmark-benchmark.o `test -f 'benchmark.c' || echo './'`benchmark.c
mv -f .deps/benchmark-benchmark.Tpo .deps/benchmark-benchmark.Po
/bin/bash ../../libtool  --tag=CC   --mode=link gcc   -g -O2 -fno-strict-aliasing   -o benchmark benchmark-benchmark.o ../../src/microhttpd/libmicrohttpd.la 
libtool: link: gcc -g -O2 -fno-strict-aliasing -o .libs/benchmark benchmark-benchmark.o  ../../src/microhttpd/.libs/libmicrohttpd.so -pthread
../../src/microhttpd/.libs/libmicrohttpd.so: undefined reference to `MHD_TLS_del_session'
../../src/microhttpd/.libs/libmicrohttpd.so: undefined reference to `MHD_TLS_del_context'
../../src/microhttpd/.libs/libmicrohttpd.so: undefined reference to `MHD_TLS_create_context'
../../src/microhttpd/.libs/libmicrohttpd.so: undefined reference to `MHD_TLS_set_context_client_certificate_mode'
../../src/microhttpd/.libs/libmicrohttpd.so: undefined reference to `MHD_TLS_set_context_certificate_cb'
../../src/microhttpd/.libs/libmicrohttpd.so: undefined reference to `MHD_TLS_session_wants_write'
../../src/microhttpd/.libs/libmicrohttpd.so: undefined reference to `MHD_set_https_callbacks'
../../src/microhttpd/.libs/libmicrohttpd.so: undefined reference to `MHD_TLS_global_deinit'
../../src/microhttpd/.libs/libmicrohttpd.so: undefined reference to `MHD_tls_connection_shutdown'
../../src/microhttpd/.libs/libmicrohttpd.so: undefined reference to `MHD_TLS_session_read'
../../src/microhttpd/.libs/libmicrohttpd.so: undefined reference to `MHD_TLS_get_session_protocol_version'
../../src/microhttpd/.libs/libmicrohttpd.so: undefined reference to `MHD_TLS_get_specific_session'
../../src/microhttpd/.libs/libmicrohttpd.so: undefined reference to `MHD_TLS_session_close'
../../src/microhttpd/.libs/libmicrohttpd.so: undefined reference to `MHD_TLS_session_read_pending'
../../src/microhttpd/.libs/libmicrohttpd.so: undefined reference to `MHD_run_tls_handshake_'
../../src/microhttpd/.libs/libmicrohttpd.so: undefined reference to `MHD_TLS_set_context_trust_certificate'
../../src/microhttpd/.libs/libmicrohttpd.so: undefined reference to `MHD_TLS_get_session_cipher_algorithm'
../../src/microhttpd/.libs/libmicrohttpd.so: undefined reference to `MHD_TLS_session_wants_read'
../../src/microhttpd/.libs/libmicrohttpd.so: undefined reference to `MHD_TLS_set_context_cipher_priorities'
../../src/microhttpd/.libs/libmicrohttpd.so: undefined reference to `MHD_TLS_lookup_engine'
../../src/microhttpd/.libs/libmicrohttpd.so: undefined reference to `MHD_TLS_create_session'
../../src/microhttpd/.libs/libmicrohttpd.so: undefined reference to `MHD_TLS_engine_has_feature'
../../src/microhttpd/.libs/libmicrohttpd.so: undefined reference to `MHD_TLS_set_context_dh_params'
../../src/microhttpd/.libs/libmicrohttpd.so: undefined reference to `MHD_TLS_global_init'
../../src/microhttpd/.libs/libmicrohttpd.so: undefined reference to `MHD_TLS_set_context_certificate'
../../src/microhttpd/.libs/libmicrohttpd.so: undefined reference to `MHD_TLS_session_write'
collect2: error: ld returned 1 exit status
Makefile:734: recipe for target 'benchmark' failed
make[4]: *** [benchmark] Error 1
make[4]: Leaving directory '/home/silvioprog/dev/git/libmicrohttpd2/src/examples'
Makefile:938: recipe for target 'all-recursive' failed
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory '/home/silvioprog/dev/git/libmicrohttpd2/src/examples'
Makefile:418: recipe for target 'all-recursive' failed
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory '/home/silvioprog/dev/git/libmicrohttpd2/src'
Makefile:549: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/silvioprog/dev/git/libmicrohttpd2'
Makefile:454: recipe for target 'all' failed
make: *** [all] Error 2


It should link openssl by itself. Another test:

./configure --with-openssl=no
make
[snip]
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../.. -I../../src/include -I../../src/microhttpd -I/usr/include/p11-kit-1 -DBUILDING_MHD_LIB=1 -fvisibility=hidden -pthread -I/usr/include/p11-kit-1 -g -O2 -fno-strict-aliasing -MT libmicrohttpd_la-connection.lo -MD -MP -MF .deps/libmicrohttpd_la-connection.Tpo -c connection.c  -fPIC -DPIC -o .libs/libmicrohttpd_la-connection.o
In file included from internal.h:32:0,
                 from connection.c:28:
tls.h:493:31: error: field ‘gnutls’ has incomplete type
     struct MHD_GnuTLS_Context gnutls;
                               ^
tls.h:529:31: error: field ‘gnutls’ has incomplete type
     struct MHD_GnuTLS_Session gnutls;
                               ^
connection.c: In function ‘MHD_get_connection_info’:
connection.c:3764:28: warning: implicit declaration of function ‘gnutls_cipher_get’ [-Wimplicit-function-declaration]
       connection->cipher = gnutls_cipher_get (connection->tls_session->d.gnutls
                            ^
connection.c:3775:30: warning: implicit declaration of function ‘gnutls_protocol_get_version’ [-Wimplicit-function-declaration]
       connection->protocol = gnutls_protocol_get_version (connection->tls_sessi
                              ^
Makefile:1182: recipe for target 'libmicrohttpd_la-connection.lo' failed
make[3]: *** [libmicrohttpd_la-connection.lo] Error 1
make[3]: Leaving directory '/home/silvioprog/dev/git/libmicrohttpd2/src/microhttpd'
Makefile:418: recipe for target 'all-recursive' failed
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory '/home/silvioprog/dev/git/libmicrohttpd2/src'
Makefile:549: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/silvioprog/dev/git/libmicrohttpd2'
Makefile:454: recipe for target 'all' failed
make: *** [all] Error 2

ghaderer

2018-02-01 08:38

reporter   ~0012851

Hello silvioprog,

Thank you for taking time to test and review my changes.

Regarding the missing symbols issue, I broke the HTTPS support auto-detection.

For the second issue, it was due to a typo which caused the build to break when GnuTLS was enabled but not OpenSSL.

I fixed both of them and pushed on the same branch. I hope I did not make other mistakes! :-/

Let me know if you have other issues or questions regarding all of this.

Christian Grothoff

2025-12-21 17:41

manager   ~0027159

Implemented in MHD2.

Issue History

Date ModifiedUsernameFieldChange
2017-02-22 20:29silvioprogNew Issue
2017-02-22 20:29silvioprogTag Attached: feature
2017-03-07 23:05Christian GrothoffProduct Version => Git master
2017-03-07 23:05Christian GrothoffSummary[FEATURE REQUEST] OpenSSL support => OpenSSL support
2017-10-13 12:36ghadererNote Added: 0012475
2018-01-31 23:07silvioprogNote Added: 0012847
2018-02-01 00:07silvioprogNote Added: 0012848
2018-02-01 08:38ghadererNote Added: 0012851
2024-01-21 12:25Christian GrothoffCategoryHTTPS (SSL) => HTTPS (TLS)
2024-01-21 12:37Christian GrothoffRelationship addedrelated to 0006671
2024-02-29 21:50Christian GrothoffTag Detached: feature
2025-09-06 23:01rootProjectlibmicrohttpd => libmicrohttpd2
2025-09-06 23:02Christian GrothoffAssigned To => Karlson2k
2025-09-06 23:02Christian GrothoffStatusnew => assigned
2025-12-21 17:41Christian GrothoffStatusassigned => resolved
2025-12-21 17:41Christian GrothoffResolutionopen => fixed
2025-12-21 17:41Christian GrothoffFixed in Version => 1.99.0
2025-12-21 17:41Christian GrothoffNote Added: 0027159
2025-12-21 17:41Christian GrothoffTarget Version => 1.99.0