From 511f8c46b77ffa2f41922eeb7dadcb6351227ba6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mudr=C3=A1k?= Date: Tue, 2 Feb 2016 22:34:04 +0100 Subject: [PATCH] MDL-52766 mnet: Support MNet peer URLs longer than 64 characters The commonName in SSL certificate is limited to 64 characters as per RFC 5280 (https://www.ietf.org/rfc/rfc5280.txt). We respect that limit when generating the CN attribute from the site's $CFG->wwwroot. But then we did not respect it when comparing the common name with the peer's URL so the certificate was not considered valid. --- mnet/peer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mnet/peer.php b/mnet/peer.php index 804b7d2dfd8..27761707932 100644 --- a/mnet/peer.php +++ b/mnet/peer.php @@ -170,7 +170,7 @@ class mnet_peer { $a['host'] = $this->wwwroot; $this->error[] = array('code' => 5, 'text' => get_string("nonmatchingcert", 'mnet', $a)); return false; - } elseif ($credentials['subject']['CN'] != $this->wwwroot) { + } else if ($credentials['subject']['CN'] !== substr($this->wwwroot, 0, 64)) { $a['subject'] = $credentials['subject']['CN']; $a['host'] = $this->wwwroot; $this->error[] = array('code' => 4, 'text' => get_string("nonmatchingcert", 'mnet', $a));