Browse Source

Updating Bug 1597 to neon 0.33

Source commit: 3472044ba62e88c89e24740087fbec2c0f840d47
Martin Prikryl 1 year ago
parent
commit
e4ed115807
2 changed files with 4 additions and 15 deletions
  1. 4 4
      libs/neon/src/ne_openssl.c
  2. 0 11
      libs/neon/src/ne_session.c

+ 4 - 4
libs/neon/src/ne_openssl.c

@@ -246,14 +246,14 @@ void ne_ssl_cert_validity_time(const ne_ssl_certificate *cert,
  * identity does not match, or <0 if the certificate had no identity.
  * If 'identity' is non-NULL, store the malloc-allocated identity in
  * *identity.  Logic specified by RFC 2818 and RFC 3280. */
-static int check_identity(const struct host_info *server, X509 *cert,
+static int check_identity(const struct host_info *server, /*WINSCP*/ const char * realhost, X509 *cert,
                           char **identity)
 {
     STACK_OF(GENERAL_NAME) *names;
     int match = 0, found = 0;
     const char *hostname;
     
-    hostname = server ? server->hostname : "";
+    hostname = realhost ? realhost : server ? server->hostname : "";
 
     names = X509_get_ext_d2i(cert, NID_subject_alt_name, NULL, NULL);
     if (names) {
@@ -346,7 +346,7 @@ static ne_ssl_certificate *populate_cert(ne_ssl_certificate *cert, X509 *x5)
     cert->subject = x5;
     /* Retrieve the cert identity; pass a dummy hostname to match. */
     cert->identity = NULL;
-    check_identity(NULL, x5, &cert->identity);
+    check_identity(NULL, /*WINSCP*/NULL, x5, &cert->identity);
     return cert;
 }
 
@@ -458,7 +458,7 @@ static int check_certificate(ne_session *sess, SSL *ssl, ne_ssl_certificate *cha
 
     /* Check certificate was issued to this server; pass URI of
      * server. */
-    ret = check_identity(&sess->server, cert, NULL);
+    ret = check_identity(&sess->server, /*WINSCP*/sess->realhost, cert, NULL);
     if (ret < 0) {
         ne_set_error(sess, _("Server certificate was missing commonName "
                              "attribute in subject name"));

+ 0 - 11
libs/neon/src/ne_session.c

@@ -481,17 +481,6 @@ void ne_set_realhost(ne_session *sess, const char *realhost)
     if (sess->realhost) ne_free(sess->realhost);
     sess->realhost = ne_strdup(realhost);
 }
-
-void ne_fill_real_server_uri(ne_session *sess, ne_uri *uri)
-{
-    ne_fill_server_uri(sess, uri);
-
-    if (sess->realhost)
-    {
-        ne_free(uri->host);
-        uri->host = ne_strdup(sess->realhost);
-    }
-}
 #endif
 
 void ne_fill_proxy_uri(ne_session *sess, ne_uri *uri)