Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: components/cronet/android/api/src/org/chromium/net/CronetEngine.java

Issue 2052363002: Enable public key pinning of local trust anchors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed CronetPerfTestActivity test Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | components/cronet/android/cronet_url_request_context_adapter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.net; 5 package org.chromium.net;
6 6
7 import android.annotation.SuppressLint; 7 import android.annotation.SuppressLint;
8 import android.content.Context; 8 import android.content.Context;
9 import android.net.http.HttpResponseCache; 9 import android.net.http.HttpResponseCache;
10 import android.support.annotation.IntDef; 10 import android.support.annotation.IntDef;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 mExpirationDate = expirationDate; 95 mExpirationDate = expirationDate;
96 } 96 }
97 } 97 }
98 98
99 private static final Pattern INVALID_PKP_HOST_NAME = Pattern.compile("^[ 0-9\\.]*$"); 99 private static final Pattern INVALID_PKP_HOST_NAME = Pattern.compile("^[ 0-9\\.]*$");
100 100
101 // Private fields are simply storage of configuration for the resulting CronetEngine. 101 // Private fields are simply storage of configuration for the resulting CronetEngine.
102 // See setters below for verbose descriptions. 102 // See setters below for verbose descriptions.
103 private final Context mContext; 103 private final Context mContext;
104 private final List<QuicHint> mQuicHints = new LinkedList<QuicHint>(); 104 private final List<QuicHint> mQuicHints = new LinkedList<QuicHint>();
105 private final List<Pkp> mPkps = new LinkedList<Pkp>(); 105 private final List<Pkp> mPkps = new LinkedList<>();
106 private boolean mPublicKeyPinningBypassForLocalTrustAnchorsEnabled;
106 private String mUserAgent; 107 private String mUserAgent;
107 private String mStoragePath; 108 private String mStoragePath;
108 private boolean mLegacyModeEnabled; 109 private boolean mLegacyModeEnabled;
109 private LibraryLoader mLibraryLoader; 110 private LibraryLoader mLibraryLoader;
110 private String mLibraryName; 111 private String mLibraryName;
111 private boolean mQuicEnabled; 112 private boolean mQuicEnabled;
112 private boolean mHttp2Enabled; 113 private boolean mHttp2Enabled;
113 private boolean mSdchEnabled; 114 private boolean mSdchEnabled;
114 private String mDataReductionProxyKey; 115 private String mDataReductionProxyKey;
115 private String mDataReductionProxyPrimaryProxy; 116 private String mDataReductionProxyPrimaryProxy;
(...skipping 12 matching lines...) Expand all
128 */ 129 */
129 public Builder(Context context) { 130 public Builder(Context context) {
130 mContext = context; 131 mContext = context;
131 setLibraryName("cronet"); 132 setLibraryName("cronet");
132 enableLegacyMode(false); 133 enableLegacyMode(false);
133 enableQUIC(false); 134 enableQUIC(false);
134 enableHTTP2(true); 135 enableHTTP2(true);
135 enableSDCH(false); 136 enableSDCH(false);
136 enableHttpCache(HTTP_CACHE_DISABLED, 0); 137 enableHttpCache(HTTP_CACHE_DISABLED, 0);
137 enableNetworkQualityEstimator(false); 138 enableNetworkQualityEstimator(false);
139 enablePublicKeyPinningBypassForLocalTrustAnchors(true);
138 } 140 }
139 141
140 /** 142 /**
141 * Constructs a User-Agent string including application name and version , 143 * Constructs a User-Agent string including application name and version ,
142 * system build version, model and id, and Cronet version. 144 * system build version, model and id, and Cronet version.
143 * 145 *
144 * @return User-Agent string. 146 * @return User-Agent string.
145 */ 147 */
146 public String getDefaultUserAgent() { 148 public String getDefaultUserAgent() {
147 return UserAgent.from(mContext); 149 return UserAgent.from(mContext);
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 539
538 /** 540 /**
539 * Returns list of public key pins. 541 * Returns list of public key pins.
540 * @return list of public key pins. 542 * @return list of public key pins.
541 */ 543 */
542 List<Pkp> publicKeyPins() { 544 List<Pkp> publicKeyPins() {
543 return mPkps; 545 return mPkps;
544 } 546 }
545 547
546 /** 548 /**
549 * Enables or disables public key pinning bypass for local trust anchors . Disabling the
550 * bypass for local trust anchors is highly discouraged since it may pro hibit the app
551 * from communicating with the pinned hosts. E.g., a user may want to se nd all traffic
552 * through an SSL enabled proxy by changing the device proxy settings an d adding the
553 * proxy certificate to the list of local trust anchor. Disabling the by pass will most
554 * likly prevent the app from sending any traffic to the pinned hosts. F or more
555 * information see 'How does key pinning interact with local proxies and filters?' at
556 * https://www.chromium.org/Home/chromium-security/security-faq
557 *
558 * @param value {@code true} to enable the bypass, {@code false} to disa ble.
559 * @return the builder to facilitate chaining.
560 */
561 public Builder enablePublicKeyPinningBypassForLocalTrustAnchors(boolean value) {
562 mPublicKeyPinningBypassForLocalTrustAnchorsEnabled = value;
563 return this;
564 }
565
566 boolean publicKeyPinningBypassForLocalTrustAnchorsEnabled() {
567 return mPublicKeyPinningBypassForLocalTrustAnchorsEnabled;
568 }
569
570 /**
547 * Checks whether a given string represents a valid host name for PKP an d converts it 571 * Checks whether a given string represents a valid host name for PKP an d converts it
548 * to ASCII Compatible Encoding representation according to RFC 1122, RF C 1123 and 572 * to ASCII Compatible Encoding representation according to RFC 1122, RF C 1123 and
549 * RFC 3490. This method is more restrictive than required by RFC 7469. Thus, a host 573 * RFC 3490. This method is more restrictive than required by RFC 7469. Thus, a host
550 * that contains digits and the dot character only is considered invalid . 574 * that contains digits and the dot character only is considered invalid .
551 * 575 *
552 * Note: Currently Cronet doesn't have native implementation of host nam e validation that 576 * Note: Currently Cronet doesn't have native implementation of host nam e validation that
553 * can be used. There is code that parses a provided URL but doesn 't ensure its 577 * can be used. There is code that parses a provided URL but doesn 't ensure its
554 * correctness. The implementation relies on {@code getaddrinfo} f unction. 578 * correctness. The implementation relies on {@code getaddrinfo} f unction.
555 * 579 *
556 * @param hostName host name to check and convert. 580 * @param hostName host name to check and convert.
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 * @hide as it's a prototype. 1171 * @hide as it's a prototype.
1148 */ 1172 */
1149 public interface RequestFinishedListener { 1173 public interface RequestFinishedListener {
1150 /** 1174 /**
1151 * Invoked with request info. 1175 * Invoked with request info.
1152 * @param requestInfo {@link UrlRequestInfo} for finished request. 1176 * @param requestInfo {@link UrlRequestInfo} for finished request.
1153 */ 1177 */
1154 void onRequestFinished(UrlRequestInfo requestInfo); 1178 void onRequestFinished(UrlRequestInfo requestInfo);
1155 } 1179 }
1156 } 1180 }
OLDNEW
« no previous file with comments | « no previous file | components/cronet/android/cronet_url_request_context_adapter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698