Commit ab404c4
committed
[HTTPCLIENT-2381] Respect system properties by default
The practical effect of this change is that default JVM configuration
for key stores (for mutual TLS) and proxy selection will be respected by
default. This change has two goals.
First, applications and libraries built on the client will work with
proxies much more reliably, since their authors no longer need to opt in
to a non-default setting in order for things like proxies to be
configurable in the usual manner (i.e. without code changes).
Second, this change, along with the change in 5.6 to make `BUILTIN` the
default `HostnameVerificationPolicy`, makes the client's configuration
philosophy fully consistent across all supported features. To wit:
1. HttpComponents _itself_ is always configured programmatically and
does not directly read system properties to obtain config values.
2. For a given feature, the default behavior is to delegate to the JDK
implementation. This implementation may support out-of-band
configuration via system properties, static methods, the
`java.security` file, system-wide OS configuration, etc.
3. This delegation behavior can be overridden by a programmatic config
option, either to directly customize the JDK-supplied implementation
or to supply an alternate implementation.
This table shows what this philosophy looks like concretely across
various features:
| Feature | Default JDK behavior | Example JDK config property | Override strategy |
| --------------------- | ---------------------------------------------- | --------------------------- | ------------------------------------------------------------------------------- |
| Trust store | Load from OS | `javax.net.ssl.trustStore` | Set a `TrustManager[]` |
| Key store | Load nothing | `javax.net.ssl.keyStore` | Set a `KeyManager[]` |
| Hostname verification | Run `HostnameChecker` from `sun.security.util` | None | Set a `HostnameVerifier` and `HostnameVerificationPolicy` |
| Proxy config | Use system properties or load from OS | `java.net.useSystemProxies` | Set a `ProxySelector` or `HttpRoutePlanner` |
| Client cipher suites | Send all supported cipher suites | `java.security.properties` | Set an `SSLContext` |
| IP family selection | Prefer IPv6 | `java.net.preferIPv4Stack` | Set a `DetachedSocketFactory` or `DnsResolver`, call `setUnixDomainSocket`, etc |
| DNS resolution | Use built-in resolver | `networkaddress.cache.ttl` | Set a `DnsResolver` |
See also the previous discussion at:
#7731 parent 6af0624 commit ab404c4
File tree
22 files changed
+63
-279
lines changed- httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent
- httpclient5-sse/src
- main/java/org/apache/hc/client5/http/sse
- test/java/org/apache/hc/client5/http/sse/example
- performance
- httpclient5/src
- main/java/org/apache/hc/client5/http
- impl
- async
- classic
- io
- nio
- ssl
- test/java/org/apache/hc/client5/http/examples
22 files changed
+63
-279
lines changedLines changed: 0 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
81 | 80 | | |
82 | 81 | | |
83 | 82 | | |
84 | 83 | | |
85 | 84 | | |
86 | 85 | | |
87 | | - | |
88 | 86 | | |
89 | 87 | | |
90 | 88 | | |
| |||
105 | 103 | | |
106 | 104 | | |
107 | 105 | | |
108 | | - | |
109 | 106 | | |
110 | 107 | | |
111 | 108 | | |
112 | 109 | | |
113 | 110 | | |
114 | 111 | | |
115 | 112 | | |
116 | | - | |
117 | 113 | | |
118 | 114 | | |
119 | 115 | | |
| |||
Lines changed: 0 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | | - | |
107 | 106 | | |
108 | 107 | | |
109 | 108 | | |
110 | 109 | | |
111 | | - | |
112 | 110 | | |
113 | 111 | | |
114 | 112 | | |
| |||
Lines changed: 0 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
71 | 70 | | |
72 | 71 | | |
73 | 72 | | |
| |||
84 | 83 | | |
85 | 84 | | |
86 | 85 | | |
87 | | - | |
88 | 86 | | |
89 | 87 | | |
90 | 88 | | |
| |||
Lines changed: 0 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | | - | |
149 | 148 | | |
150 | 149 | | |
151 | 150 | | |
| |||
161 | 160 | | |
162 | 161 | | |
163 | 162 | | |
164 | | - | |
165 | 163 | | |
166 | 164 | | |
167 | 165 | | |
| |||
Lines changed: 0 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
111 | 110 | | |
112 | 111 | | |
113 | 112 | | |
| |||
123 | 122 | | |
124 | 123 | | |
125 | 124 | | |
126 | | - | |
127 | 125 | | |
128 | 126 | | |
129 | 127 | | |
| |||
Lines changed: 0 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
94 | 93 | | |
95 | 94 | | |
96 | 95 | | |
| |||
107 | 106 | | |
108 | 107 | | |
109 | 108 | | |
110 | | - | |
111 | 109 | | |
112 | 110 | | |
113 | 111 | | |
| |||
Lines changed: 5 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
59 | 58 | | |
60 | 59 | | |
61 | 60 | | |
| |||
201 | 200 | | |
202 | 201 | | |
203 | 202 | | |
204 | | - | |
205 | 203 | | |
206 | 204 | | |
207 | 205 | | |
| |||
669 | 667 | | |
670 | 668 | | |
671 | 669 | | |
672 | | - | |
673 | | - | |
| 670 | + | |
674 | 671 | | |
| 672 | + | |
675 | 673 | | |
676 | 674 | | |
| 675 | + | |
677 | 676 | | |
678 | | - | |
679 | 677 | | |
680 | 678 | | |
681 | 679 | | |
| |||
964 | 962 | | |
965 | 963 | | |
966 | 964 | | |
967 | | - | |
968 | | - | |
969 | | - | |
970 | | - | |
971 | | - | |
| 965 | + | |
972 | 966 | | |
973 | 967 | | |
974 | 968 | | |
975 | 969 | | |
976 | | - | |
977 | | - | |
978 | | - | |
979 | | - | |
980 | | - | |
| 970 | + | |
981 | 971 | | |
982 | 972 | | |
983 | 973 | | |
| |||
Lines changed: 6 additions & 33 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
69 | 68 | | |
70 | 69 | | |
71 | 70 | | |
72 | 71 | | |
73 | 72 | | |
74 | 73 | | |
75 | 74 | | |
76 | | - | |
77 | 75 | | |
78 | 76 | | |
79 | 77 | | |
| |||
137 | 135 | | |
138 | 136 | | |
139 | 137 | | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | 138 | | |
155 | 139 | | |
156 | 140 | | |
| |||
252 | 236 | | |
253 | 237 | | |
254 | 238 | | |
255 | | - | |
256 | 239 | | |
257 | 240 | | |
258 | 241 | | |
| |||
776 | 759 | | |
777 | 760 | | |
778 | 761 | | |
779 | | - | |
780 | | - | |
| 762 | + | |
781 | 763 | | |
| 764 | + | |
782 | 765 | | |
783 | 766 | | |
| 767 | + | |
784 | 768 | | |
785 | | - | |
786 | 769 | | |
787 | 770 | | |
788 | 771 | | |
| |||
1010 | 993 | | |
1011 | 994 | | |
1012 | 995 | | |
1013 | | - | |
1014 | | - | |
1015 | | - | |
1016 | | - | |
1017 | | - | |
| 996 | + | |
1018 | 997 | | |
1019 | 998 | | |
1020 | 999 | | |
| |||
1166 | 1145 | | |
1167 | 1146 | | |
1168 | 1147 | | |
1169 | | - | |
| 1148 | + | |
1170 | 1149 | | |
1171 | 1150 | | |
1172 | | - | |
1173 | | - | |
1174 | 1151 | | |
1175 | 1152 | | |
1176 | 1153 | | |
| |||
1276 | 1253 | | |
1277 | 1254 | | |
1278 | 1255 | | |
1279 | | - | |
1280 | | - | |
1281 | | - | |
1282 | | - | |
1283 | | - | |
| 1256 | + | |
1284 | 1257 | | |
1285 | 1258 | | |
1286 | 1259 | | |
| |||
Lines changed: 9 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| 92 | + | |
| 93 | + | |
92 | 94 | | |
| 95 | + | |
93 | 96 | | |
94 | | - | |
| 97 | + | |
95 | 98 | | |
96 | 99 | | |
97 | 100 | | |
| |||
112 | 115 | | |
113 | 116 | | |
114 | 117 | | |
115 | | - | |
116 | | - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
117 | 121 | | |
| 122 | + | |
118 | 123 | | |
119 | | - | |
| 124 | + | |
120 | 125 | | |
121 | 126 | | |
122 | 127 | | |
| |||
0 commit comments