After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 739951 - [regression] Doesn't run GTlsConnection for https:// requests
[regression] Doesn't run GTlsConnection for https:// requests
Status: RESOLVED FIXED
Product: libsoup
Classification: Core
Component: HTTP Transport
2.48.x
Other Linux
: Normal major
: ---
Assigned To: libsoup-maint@gnome.bugs
libsoup-maint@gnome.bugs
: 740402 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2014-11-11 10:47 UTC by Milan Crha
Modified: 2014-12-01 20:07 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
test-soup.c (2.71 KB, text/plain)
2014-11-11 10:47 UTC, Milan Crha
Details

Description Milan Crha 2014-11-11 10:47:36 UTC
Created attachment 290405 [details]
test-soup.c

I just realized I cannot connect to a server using https:// GET with libsoup 2.48.0 and glib-networking 2.42.0, but 2.40.0 is also broken. The problem is that if the server uses a certificate with an unknown CA, then the handshake fails with "Unacceptable TLS certificate", instead of expected "SSL handshake failed" (the case for libsoup-2.44.2 and glib-networking-2.38.2).

Further investigation showed that the "network-event" of a SoupMessage uses GTcpConnection for G_SOCKET_CLIENT_TLS_HANDSHAKING, while it should use a GTlsConnection descendant, like GTlsClientConnectionGnutls in case of the older versions.

This bug prevents evolution-data-server's CalDAV calendar to connect to servers with "bad" certificate (and possibly other parts using libsoup).

Attached is a minimal reproducer. The network_event_cb() is simplified, evolution-data-server's code adds a signal handler for "accept-certificate" there [1].

[1] https://git.gnome.org/browse/evolution-data-server/tree/libebackend/e-soup-ssl-trust.c#n109
Comment 1 Dan Winship 2014-11-23 22:25:42 UTC
Thanks for the reproducer. Fixed in master.

I didn't put out point releases for 3.14.1 or 3.14.2, so I'll probably do a stable release soon.
Comment 2 Fryderyk Dziarmagowski 2014-11-30 10:15:38 UTC
Does not see any change after applying the fix to 2.48.0

% ./test-soup
Hello...
   network_event_cb: handshaking:0 (0) is tls:0 (null)
   network_event_cb: handshaking:0 (1) is tls:0 (null)
   network_event_cb: handshaking:0 (2) is tls:0 (GTcpConnection)
   network_event_cb: handshaking:0 (3) is tls:0 (GTcpConnection)
   network_event_cb: handshaking:1 (6) is tls:1 (GTlsClientConnectionGnutls)
test_thread: Failed, certflags:1 code:6 reason:Unacceptable TLS certificate
Bye...

But libsoup-included test runs just fine
% ./connection-test
/connection/content-length-framing: OK
/connection/persistent-connection-timeout: OK
/connection/max-conns: OK
/connection/non-persistent: OK
/connection/non-idempotent: OK
/connection/state: OK
/connection/event: OK
Comment 3 Dan Winship 2014-11-30 20:06:48 UTC
are you sure "test-soup" is linked against the new libsoup build? (eg, what does "ldd ./test-soup" show?)
Comment 4 Fryderyk Dziarmagowski 2014-11-30 21:17:05 UTC
pretty much sure:

% ldd ./test-soup | grep soup
	libsoup-2.4.so.1 => /usr/lib64/libsoup-2.4.so.1 (0x00007fa060f8b000)

% file /usr/lib64/libsoup-2.4.so.1.7.0
/usr/lib64/libsoup-2.4.so.1.7.0: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=1bc3049df754a25dffe31d4098ad89391ee7cedf, stripped

% file ~/builder/rpm/BUILD/libsoup-2.48.0/libsoup/.libs/libsoup-2.4.so.1.7.0
/home/users/fritz/builder/rpm/BUILD/libsoup-2.48.0/libsoup/.libs/libsoup-2.4.so.1.7.0: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=1bc3049df754a25dffe31d4098ad89391ee7cedf, not stripped

[builder@builder64 libsoup-2.48.0]$ grep soup_socket_event ~/rpm/BUILD/libsoup-2.48.0/libsoup/*.c                                                                                    
/home/users/builder/rpm/BUILD/libsoup-2.48.0/libsoup/soup-socket.c:soup_socket_event (SoupSocket         *sock,
/home/users/builder/rpm/BUILD/libsoup-2.48.0/libsoup/soup-socket.c:	soup_socket_event (sock, event, connection);
/home/users/builder/rpm/BUILD/libsoup-2.48.0/libsoup/soup-socket.c:	soup_socket_event (sock, G_SOCKET_CLIENT_TLS_HANDSHAKING, priv->conn);
/home/users/builder/rpm/BUILD/libsoup-2.48.0/libsoup/soup-socket.c:	soup_socket_event (sock, G_SOCKET_CLIENT_TLS_HANDSHAKED, priv->conn);
/home/users/builder/rpm/BUILD/libsoup-2.48.0/libsoup/soup-socket.c:		soup_socket_event (sock, G_SOCKET_CLIENT_TLS_HANDSHAKED, priv->conn);
/home/users/builder/rpm/BUILD/libsoup-2.48.0/libsoup/soup-socket.c:	soup_socket_event (sock, G_SOCKET_CLIENT_TLS_HANDSHAKING, priv->conn);
Comment 5 Milan Crha 2014-12-01 13:04:14 UTC
*** Bug 740402 has been marked as a duplicate of this bug. ***
Comment 6 Milan Crha 2014-12-01 13:32:52 UTC
I can confirm that the fix [1] works. The thing is that this:

> Hello...
>    network_event_cb: handshaking:0 (0) is tls:0 (null)
>    network_event_cb: handshaking:0 (1) is tls:0 (null)
>    network_event_cb: handshaking:0 (2) is tls:0 (GTcpConnection)
>    network_event_cb: handshaking:0 (3) is tls:0 (GTcpConnection)
>    network_event_cb: handshaking:1 (6) is tls:1 (GTlsClientConnectionGnutls)
> test_thread: Failed, certflags:1 code:6 reason:Unacceptable TLS certificate

used to be (before [1]):

> Hello...
>    network_event_cb: handshaking:0 (0) is tls:0 (null)
>    network_event_cb: handshaking:0 (1) is tls:0 (null)
>    network_event_cb: handshaking:0 (2) is tls:0 (GTcpConnection)
>    network_event_cb: handshaking:0 (3) is tls:0 (GTcpConnection)
>    network_event_cb: handshaking:1 (6) is tls:0 (GTcpConnection)
> test_thread: Failed, certflags:1 code:6 reason:Unacceptable TLS certificate

aka the network_event 6 was not done on a TLS connection, which broke
evolution-data-server. The change [1] still shows the same reason (the last line), but it's not an issue.

[1] https://git.gnome.org/browse/libsoup/commit/?h=gnome-3-14&id=c8ff05b7308818b914ab7738fdaf3dbf5fa11e16
Comment 7 Milan Crha 2014-12-01 13:33:07 UTC
Dan, please do the release of libsoup, there will be more and more people affected, which is not good.
Comment 8 Fryderyk Dziarmagowski 2014-12-01 20:07:22 UTC
@Milan: thanks for clarification. So all these "Peer failed to perform TLS handshake" are not related... Sorry for the noise.