michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsISupports.idl" michael@0: michael@0: interface nsIURI; michael@0: interface nsIObserver; michael@0: interface nsIHttpChannel; michael@0: michael@0: [scriptable, uuid(b20a9242-5732-45bc-9fa0-a178154f2721)] michael@0: interface nsISiteSecurityService : nsISupports michael@0: { michael@0: const uint32_t HEADER_HSTS = 0; michael@0: const uint32_t HEADER_HKPK = 1; michael@0: const uint32_t HEADER_OMS = 2; michael@0: michael@0: /** michael@0: * Parses a given HTTP header and records the results internally. michael@0: * Currently the only header type supported is HSTS (aka STS). michael@0: * The format of the HSTS header is defined by the HSTS specification: michael@0: * https://tools.ietf.org/html/rfc6797 michael@0: * and allows a host to specify that future HTTP requests should be michael@0: * upgraded to HTTPS. michael@0: * michael@0: * @param aType the type of security header in question. michael@0: * @param aSourceURI the URI of the resource with the HTTP header. michael@0: * @param aHeader the HTTP response header specifying security data. michael@0: * @param aFlags options for this request as defined in nsISocketProvider: michael@0: * NO_PERMANENT_STORAGE michael@0: * @param aMaxAge the parsed max-age directive of the header. michael@0: * @param aIncludeSubdomains the parsed includeSubdomains directive. michael@0: * @return NS_OK if it succeeds michael@0: * NS_ERROR_FAILURE if it can't be parsed michael@0: * NS_SUCCESS_LOSS_OF_INSIGNIFICANT_DATA michael@0: * if there are unrecognized tokens in the header. michael@0: */ michael@0: void processHeader(in uint32_t aType, michael@0: in nsIURI aSourceURI, michael@0: in string aHeader, michael@0: in uint32_t aFlags, michael@0: [optional] out unsigned long long aMaxAge, michael@0: [optional] out boolean aIncludeSubdomains); michael@0: michael@0: /** michael@0: * Given a header type, removes state relating to that header of a host, michael@0: * including the includeSubdomains state that would affect subdomains. michael@0: * This essentially removes the state for the domain tree rooted at this michael@0: * host. michael@0: * @param aType the type of security state in question michael@0: * @param aURI the URI of the target host michael@0: * @param aFlags options for this request as defined in nsISocketProvider: michael@0: * NO_PERMANENT_STORAGE michael@0: */ michael@0: void removeState(in uint32_t aType, michael@0: in nsIURI aURI, michael@0: in uint32_t aFlags); michael@0: michael@0: /** michael@0: * See isSecureURI michael@0: * michael@0: * @param aType the type of security state in question. michael@0: * @param aHost the hostname (punycode) to query for state. michael@0: * @param aFlags options for this request as defined in nsISocketProvider: michael@0: * NO_PERMANENT_STORAGE michael@0: */ michael@0: boolean isSecureHost(in uint32_t aType, michael@0: in string aHost, michael@0: in uint32_t aFlags); michael@0: michael@0: /** michael@0: * Checks if the given security info is for a host with a broken michael@0: * transport layer (certificate errors like invalid CN). michael@0: */ michael@0: boolean shouldIgnoreHeaders(in nsISupports aSecurityInfo); michael@0: michael@0: /** michael@0: * Checks whether or not the URI's hostname has a given security state set. michael@0: * For example, for HSTS: michael@0: * The URI is an HSTS URI if either the host has the HSTS state set, or one michael@0: * of its super-domains has the HSTS "includeSubdomains" flag set. michael@0: * NOTE: this function makes decisions based only on the michael@0: * host contained in the URI, and disregards other portions of the URI michael@0: * such as path and port. michael@0: * michael@0: * @param aType the type of security state in question. michael@0: * @param aURI the URI to query for STS state. michael@0: * @param aFlags options for this request as defined in nsISocketProvider: michael@0: * NO_PERMANENT_STORAGE michael@0: */ michael@0: boolean isSecureURI(in uint32_t aType, in nsIURI aURI, in uint32_t aFlags); michael@0: michael@0: }; michael@0: michael@0: %{C++ michael@0: #define NS_SSSERVICE_CONTRACTID "@mozilla.org/ssservice;1" michael@0: michael@0: #define STS_PERMISSION "sts/use" michael@0: #define STS_SUBDOMAIN_PERMISSION "sts/subd" michael@0: %}