示例#1
0
        internal override bool TryRequireSsl(out Identifier secureIdentifier)
        {
            // If this Identifier is already secure, reuse it.
            if (IsDiscoverySecureEndToEnd)
            {
                secureIdentifier = this;
                return(true);
            }

            // If this identifier already uses SSL for initial discovery, return one
            // that guarantees it will be used throughout the discovery process.
            if (String.Equals(Uri.Scheme, Uri.UriSchemeHttps, StringComparison.OrdinalIgnoreCase))
            {
                secureIdentifier = new UriIdentifier(this.Uri, true);
                return(true);
            }

            // Otherwise, try to make this Identifier secure by normalizing to HTTPS instead of HTTP.
            if (SchemeImplicitlyPrepended)
            {
                UriBuilder newIdentifierUri = new UriBuilder(this.Uri);
                newIdentifierUri.Scheme = Uri.UriSchemeHttps;
                if (newIdentifierUri.Port == 80)
                {
                    newIdentifierUri.Port = 443;
                }
                secureIdentifier = new UriIdentifier(newIdentifierUri.Uri, true);
                return(true);
            }

            // This identifier is explicitly NOT https, so we cannot change it.
            secureIdentifier = new NoDiscoveryIdentifier(this);
            return(false);
        }
示例#2
0
        internal override bool TryRequireSsl(out Identifier secureIdentifier)
        {
            // If this Identifier is already secure, reuse it.
            if (IsDiscoverySecureEndToEnd) {
                secureIdentifier = this;
                return true;
            }

            // If this identifier already uses SSL for initial discovery, return one
            // that guarantees it will be used throughout the discovery process.
            if (String.Equals(Uri.Scheme, Uri.UriSchemeHttps, StringComparison.OrdinalIgnoreCase)) {
                secureIdentifier = new UriIdentifier(this.Uri, true);
                return true;
            }

            // Otherwise, try to make this Identifier secure by normalizing to HTTPS instead of HTTP.
            if (SchemeImplicitlyPrepended) {
                UriBuilder newIdentifierUri = new UriBuilder(this.Uri);
                newIdentifierUri.Scheme = Uri.UriSchemeHttps;
                if (newIdentifierUri.Port == 80) {
                    newIdentifierUri.Port = 443;
                }
                secureIdentifier = new UriIdentifier(newIdentifierUri.Uri, true);
                return true;
            }

            // This identifier is explicitly NOT https, so we cannot change it.
            secureIdentifier = new NoDiscoveryIdentifier(this);
            return false;
        }