diff --git a/daemon/gvfsbackendftp.c b/daemon/gvfsbackendftp.c
index e80e464..ffdd9da 100644
--- a/daemon/gvfsbackendftp.c
+++ b/daemon/gvfsbackendftp.c
@@ -48,6 +48,9 @@
 
 #include "ParseFTPList.h"
 
+/* FIXME: ugly hack to get access to libsoups private credentials function. */
+gpointer soup_ssl_get_client_credentials (const char *ca_file);
+
 #define PRINT_DEBUG
 
 #ifdef PRINT_DEBUG
@@ -98,6 +101,8 @@ typedef enum {
   FTP_FEATURE_TVFS = (1 << 2),
   FTP_FEATURE_EPSV = (1 << 3),
   FTP_FEATURE_UTF8 = (1 << 4),
+  FTP_FEATURE_TLS = (1 << 5),
+  FTP_FEATURE_SSL = (1 << 6),
 } FtpFeatures;
 #define FTP_FEATURES_DEFAULT (FTP_FEATURE_EPSV)
 
@@ -645,6 +650,8 @@ ftp_connection_parse_features (FtpConnection *conn)
     { "TVFS", FTP_FEATURE_TVFS },
     { "EPSV", FTP_FEATURE_EPSV },
     { "UTF8", FTP_FEATURE_UTF8 },
+    { "AUTH TLS", FTP_FEATURE_TLS },
+    { "AUTH SSL", FTP_FEATURE_SSL },
   };
   char **supported;
   guint i, j;
@@ -775,6 +782,8 @@ ftp_connection_parse_system (FtpConnection *conn)
 static void
 ftp_connection_prepare (FtpConnection *conn)
 {
+  gboolean do_ssl = FALSE;
+
   /* check supported features */
   if (ftp_connection_send (conn, 0, "FEAT") != 0) {
     ftp_connection_parse_features (conn);
@@ -784,6 +793,23 @@ ftp_connection_prepare (FtpConnection *conn)
     conn->features = 0;
   }
 
+  /* initialize security extension */
+  if (conn->features & FTP_FEATURE_TLS) {
+    if (ftp_connection_send (conn, 0, "AUTH TLS"))
+      do_ssl = TRUE;
+  } else if (conn->features & FTP_FEATURE_SSL) {
+    if (ftp_connection_send (conn, 0, "AUTH SSL"))
+      do_ssl = TRUE;
+  }
+
+  if (do_ssl) {
+    GValue creds = { 0, };
+    g_value_init (&creds, G_TYPE_POINTER);
+    g_value_set_pointer (&creds, soup_ssl_get_client_credentials(NULL));
+    g_object_set_property (G_OBJECT(conn->commands), "ssl-creds", &creds);
+    soup_socket_start_ssl (conn->commands, NULL);
+  }
+
   /* instruct server that we'll give and assume we get utf8 */
   if (conn->features & FTP_FEATURE_UTF8)
     ftp_connection_send (conn, 0, "OPTS UTF8 ON");
