vishalmishra434 / rpms / openssh

Forked from rpms/openssh a month ago
Clone
Petr Lautrbach d271e0
diff --git a/ChangeLog b/ChangeLog
Petr Lautrbach 94c6f8
index 38de846..1603a07 100644
Petr Lautrbach d271e0
--- a/ChangeLog
Petr Lautrbach d271e0
+++ b/ChangeLog
Petr Lautrbach d271e0
@@ -1,3 +1,14 @@
Petr Lautrbach d271e0
+20140420
Petr Lautrbach d271e0
+   - djm@cvs.openbsd.org 2014/04/01 03:34:10
Petr Lautrbach d271e0
+     [sshconnect.c]
Petr Lautrbach d271e0
+     When using VerifyHostKeyDNS with a DNSSEC resolver, down-convert any
Petr Lautrbach d271e0
+     certificate keys to plain keys and attempt SSHFP resolution.
Petr Lautrbach d271e0
+     
Petr Lautrbach d271e0
+     Prevents a server from skipping SSHFP lookup and forcing a new-hostkey
Petr Lautrbach d271e0
+     dialog by offering only certificate keys.
Petr Lautrbach d271e0
+     
Petr Lautrbach d271e0
+     Reported by mcv21 AT cam.ac.uk
Petr Lautrbach d271e0
+
Petr Lautrbach 94c6f8
 20140313
Petr Lautrbach 94c6f8
  - (djm) Release OpenSSH 6.6
Petr Lautrbach 94c6f8
 
Petr Lautrbach d271e0
diff --git a/sshconnect.c b/sshconnect.c
Petr Lautrbach 94c6f8
index 394cca8..e636f33 100644
Petr Lautrbach d271e0
--- a/sshconnect.c
Petr Lautrbach d271e0
+++ b/sshconnect.c
Petr Lautrbach 94c6f8
@@ -1219,30 +1219,40 @@ verify_host_key(char *host, struct sockaddr *hostaddr, Key *host_key)
Petr Lautrbach d271e0
 {
Petr Lautrbach d271e0
 	int flags = 0;
Petr Lautrbach d271e0
 	char *fp;
Petr Lautrbach d271e0
+	Key *plain = NULL;
Petr Lautrbach d271e0
 
Petr Lautrbach d271e0
 	fp = key_selected_fingerprint(host_key, SSH_FP_HEX);
Petr Lautrbach d271e0
 	debug("Server host key: %s %s%s", key_type(host_key),
Petr Lautrbach d271e0
 	    key_fingerprint_prefix(), fp);
Petr Lautrbach d271e0
 	free(fp);
Petr Lautrbach d271e0
 
Petr Lautrbach d271e0
-	/* XXX certs are not yet supported for DNS */
Petr Lautrbach d271e0
-	if (!key_is_cert(host_key) && options.verify_host_key_dns &&
Petr Lautrbach d271e0
-	    verify_host_key_dns(host, hostaddr, host_key, &flags) == 0) {
Petr Lautrbach d271e0
-		if (flags & DNS_VERIFY_FOUND) {
Petr Lautrbach d271e0
-
Petr Lautrbach d271e0
-			if (options.verify_host_key_dns == 1 &&
Petr Lautrbach d271e0
-			    flags & DNS_VERIFY_MATCH &&
Petr Lautrbach d271e0
-			    flags & DNS_VERIFY_SECURE)
Petr Lautrbach d271e0
-				return 0;
Petr Lautrbach d271e0
-
Petr Lautrbach d271e0
-			if (flags & DNS_VERIFY_MATCH) {
Petr Lautrbach d271e0
-				matching_host_key_dns = 1;
Petr Lautrbach d271e0
-			} else {
Petr Lautrbach d271e0
-				warn_changed_key(host_key);
Petr Lautrbach d271e0
-				error("Update the SSHFP RR in DNS with the new "
Petr Lautrbach d271e0
-				    "host key to get rid of this message.");
Petr Lautrbach d271e0
+	if (options.verify_host_key_dns) {
Petr Lautrbach d271e0
+		/*
Petr Lautrbach d271e0
+		 * XXX certs are not yet supported for DNS, so downgrade
Petr Lautrbach d271e0
+		 * them and try the plain key.
Petr Lautrbach d271e0
+		 */
Petr Lautrbach d271e0
+		plain = key_from_private(host_key);
Petr Lautrbach d271e0
+		if (key_is_cert(plain))
Petr Lautrbach d271e0
+			key_drop_cert(plain);
Petr Lautrbach d271e0
+		if (verify_host_key_dns(host, hostaddr, plain, &flags) == 0) {
Petr Lautrbach d271e0
+			if (flags & DNS_VERIFY_FOUND) {
Petr Lautrbach d271e0
+				if (options.verify_host_key_dns == 1 &&
Petr Lautrbach d271e0
+				    flags & DNS_VERIFY_MATCH &&
Petr Lautrbach d271e0
+				    flags & DNS_VERIFY_SECURE) {
Petr Lautrbach d271e0
+					key_free(plain);
Petr Lautrbach d271e0
+					return 0;
Petr Lautrbach d271e0
+				}
Petr Lautrbach d271e0
+				if (flags & DNS_VERIFY_MATCH) {
Petr Lautrbach d271e0
+					matching_host_key_dns = 1;
Petr Lautrbach d271e0
+				} else {
Petr Lautrbach d271e0
+					warn_changed_key(plain);
Petr Lautrbach d271e0
+					error("Update the SSHFP RR in DNS "
Petr Lautrbach d271e0
+					    "with the new host key to get rid "
Petr Lautrbach d271e0
+					    "of this message.");
Petr Lautrbach d271e0
+				}
Petr Lautrbach d271e0
 			}
Petr Lautrbach d271e0
 		}
Petr Lautrbach d271e0
+		key_free(plain);
Petr Lautrbach d271e0
 	}
Petr Lautrbach d271e0
 
Petr Lautrbach d271e0
 	return check_host_key(host, hostaddr, options.port, host_key, RDRW,