src/wp-includes/link-template.php:3220: trailing whitespace.
+ * 



diff --git a/src/wp-includes/link-template.php b/src/wp-includes/link-template.php
index 58b722c..1200d89 100644
--- a/src/wp-includes/link-template.php
+++ b/src/wp-includes/link-template.php
@@ -3216,6 +3216,8 @@ function get_edit_profile_url( $user_id = 0, $scheme = 'admin' ) {
 /**
  * Output rel=canonical for singular queries.
  *
+ * Ensure the canonical URL's scheme matches the scheme of home_url
+ * 
  * @since 2.9.0
 */
 function rel_canonical() {
@@ -3231,6 +3233,17 @@ function rel_canonical() {
 	if ( $page = get_query_var('cpage') )
 		$link = get_comments_pagenum_link( $page );
 
+	$home = get_option( 'home' );
+	$canonical_scheme = parse_url( $home, PHP_URL_SCHEME );
+
+	if ( ! in_array( $canonical_scheme, array( 'http', 'https', 'relative' ) ) ) {
+		if ( is_ssl() && ! is_admin() && 'wp-login.php' !== $GLOBALS['pagenow'] ) {
+			$canonical_scheme = 'https';
+		}
+	}
+
+	$link = set_url_scheme( $link, $canonical_scheme );
+
 	echo "<link rel='canonical' href='$link' />\n";
 }
 
