core: "null server certificate" cleanup in certificate.c
authorMads Kiilerich <mads@kiilerich.com>
Tue, 28 Feb 2012 20:31:09 +0000 (21:31 +0100)
committerMads Kiilerich <mads@kiilerich.com>
Tue, 28 Feb 2012 20:31:09 +0000 (21:31 +0100)
"null server certificate" is not an error. It is usually seen when the
certificate already has been sent and the server doesn't send it twice just
because of licensing. Degrading to debug message.

Do the check early to avoid leaking a stream.

Also remove unused static strings.

libfreerdp-core/certificate.c

index 22c47c2..93c9958 100644 (file)
@@ -27,9 +27,6 @@
 
 #include <freerdp/utils/file.h>
 
-static const char certificate_store_dir[] = "certs";
-static const char certificate_known_hosts_file[] = "known_hosts";
-
 #include "certificate.h"
 
 /**
@@ -448,15 +445,16 @@ boolean certificate_read_server_certificate(rdpCertificate* certificate, uint8*
        STREAM* s;
        uint32 dwVersion;
 
-       s = stream_new(0);
-       stream_attach(s, server_cert, length);
-
+       printf("length %d\n", length);
        if (length < 1)
        {
-               printf("null server certificate\n");
+               DEBUG_CERTIFICATE("null server certificate\n");
                return false;
        }
 
+       s = stream_new(0);
+       stream_attach(s, server_cert, length);
+
        stream_read_uint32(s, dwVersion); /* dwVersion (4 bytes) */
 
        switch (dwVersion & CERT_CHAIN_VERSION_MASK)