author | wetmore |
Fri, 11 May 2018 15:53:12 -0700 | |
branch | JDK-8145252-TLS13-branch |
changeset 56542 | 56aaa6cb3693 |
parent 47216 | 71c04702a3d5 |
child 55353 | 946f7f2d321c |
permissions | -rw-r--r-- |
14194
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
1 |
/* |
56542 | 2 |
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. |
14194
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
4 |
* |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
10 |
* |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
15 |
* accompanied this code). |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
16 |
* |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
20 |
* |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
23 |
* questions. |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
24 |
*/ |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
25 |
|
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
26 |
package sun.security.ssl; |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
27 |
|
56542 | 28 |
import java.math.BigInteger; |
14194
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
29 |
import java.util.*; |
56542 | 30 |
import java.util.regex.Pattern; |
31 |
import javax.net.ssl.*; |
|
14194
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
32 |
import sun.net.util.IPAddressUtil; |
56542 | 33 |
import sun.security.action.GetPropertyAction; |
14194
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
34 |
|
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
35 |
/** |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
36 |
* A utility class to share the static methods. |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
37 |
*/ |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
38 |
final class Utilities { |
38463 | 39 |
static final char[] hexDigits = "0123456789ABCDEF".toCharArray(); |
56542 | 40 |
private static final String indent = " "; |
41 |
private static final Pattern lineBreakPatern = |
|
42 |
Pattern.compile("\\r\\n|\\n|\\r"); |
|
38463 | 43 |
|
44 |
/** |
|
14194
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
45 |
* Puts {@code hostname} into the {@code serverNames} list. |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
46 |
* <P> |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
47 |
* If the {@code serverNames} does not look like a legal FQDN, it will |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
48 |
* not be put into the returned list. |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
49 |
* <P> |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
50 |
* Note that the returned list does not allow duplicated name type. |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
51 |
* |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
52 |
* @return a list of {@link SNIServerName} |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
53 |
*/ |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
54 |
static List<SNIServerName> addToSNIServerNameList( |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
55 |
List<SNIServerName> serverNames, String hostname) { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
56 |
|
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
57 |
SNIHostName sniHostName = rawToSNIHostName(hostname); |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
58 |
if (sniHostName == null) { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
59 |
return serverNames; |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
60 |
} |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
61 |
|
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
62 |
int size = serverNames.size(); |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
63 |
List<SNIServerName> sniList = (size != 0) ? |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
64 |
new ArrayList<SNIServerName>(serverNames) : |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
65 |
new ArrayList<SNIServerName>(1); |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
66 |
|
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
67 |
boolean reset = false; |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
68 |
for (int i = 0; i < size; i++) { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
69 |
SNIServerName serverName = sniList.get(i); |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
70 |
if (serverName.getType() == StandardConstants.SNI_HOST_NAME) { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
71 |
sniList.set(i, sniHostName); |
56542 | 72 |
if (SSLLogger.isOn && SSLLogger.isOn("ssl")) { |
73 |
SSLLogger.fine( |
|
74 |
"the previous server name in SNI (" + serverName + |
|
14194
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
75 |
") was replaced with (" + sniHostName + ")"); |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
76 |
} |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
77 |
reset = true; |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
78 |
break; |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
79 |
} |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
80 |
} |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
81 |
|
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
82 |
if (!reset) { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
83 |
sniList.add(sniHostName); |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
84 |
} |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
85 |
|
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
86 |
return Collections.<SNIServerName>unmodifiableList(sniList); |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
87 |
} |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
88 |
|
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
89 |
/** |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
90 |
* Converts string hostname to {@code SNIHostName}. |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
91 |
* <P> |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
92 |
* Note that to check whether a hostname is a valid domain name, we cannot |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
93 |
* use the hostname resolved from name services. For virtual hosting, |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
94 |
* multiple hostnames may be bound to the same IP address, so the hostname |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
95 |
* resolved from name services is not always reliable. |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
96 |
* |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
97 |
* @param hostname |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
98 |
* the raw hostname |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
99 |
* @return an instance of {@link SNIHostName}, or null if the hostname does |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
100 |
* not look like a FQDN |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
101 |
*/ |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
102 |
private static SNIHostName rawToSNIHostName(String hostname) { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
103 |
SNIHostName sniHostName = null; |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
104 |
if (hostname != null && hostname.indexOf('.') > 0 && |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
105 |
!hostname.endsWith(".") && |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
106 |
!IPAddressUtil.isIPv4LiteralAddress(hostname) && |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
107 |
!IPAddressUtil.isIPv6LiteralAddress(hostname)) { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
108 |
|
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
109 |
try { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
110 |
sniHostName = new SNIHostName(hostname); |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
111 |
} catch (IllegalArgumentException iae) { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
112 |
// don't bother to handle illegal host_name |
56542 | 113 |
if (SSLLogger.isOn && SSLLogger.isOn("ssl")) { |
114 |
SSLLogger.fine(hostname + "\" " + |
|
14194
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
115 |
"is not a legal HostName for server name indication"); |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
116 |
} |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
117 |
} |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
118 |
} |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
119 |
|
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
120 |
return sniHostName; |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
121 |
} |
56542 | 122 |
|
123 |
/** |
|
124 |
* Return the value of the boolean System property propName. |
|
125 |
* |
|
126 |
* Note use of privileged action. Do NOT make accessible to applications. |
|
127 |
*/ |
|
128 |
static boolean getBooleanProperty(String propName, boolean defaultValue) { |
|
129 |
// if set, require value of either true or false |
|
130 |
String b = GetPropertyAction.privilegedGetProperty(propName); |
|
131 |
if (b == null) { |
|
132 |
return defaultValue; |
|
133 |
} else if (b.equalsIgnoreCase("false")) { |
|
134 |
return false; |
|
135 |
} else if (b.equalsIgnoreCase("true")) { |
|
136 |
return true; |
|
137 |
} else { |
|
138 |
throw new RuntimeException("Value of " + propName |
|
139 |
+ " must either be 'true' or 'false'"); |
|
140 |
} |
|
141 |
} |
|
142 |
||
143 |
static String indent(String source) { |
|
144 |
return Utilities.indent(source, indent); |
|
145 |
} |
|
146 |
||
147 |
static String indent(String source, String prefix) { |
|
148 |
StringBuilder builder = new StringBuilder(); |
|
149 |
if (source == null) { |
|
150 |
builder.append("\n" + prefix + "<blank message>"); |
|
151 |
} else { |
|
152 |
String[] lines = lineBreakPatern.split(source); |
|
153 |
boolean isFirst = true; |
|
154 |
for (String line : lines) { |
|
155 |
if (isFirst) { |
|
156 |
isFirst = false; |
|
157 |
} else { |
|
158 |
builder.append("\n"); |
|
159 |
} |
|
160 |
builder.append(prefix).append(line); |
|
161 |
} |
|
162 |
} |
|
163 |
||
164 |
return builder.toString(); |
|
165 |
} |
|
166 |
||
167 |
static String toHexString(byte b) { |
|
168 |
return String.valueOf(hexDigits[(b >> 4) & 0x0F]) + |
|
169 |
String.valueOf(hexDigits[b & 0x0F]); |
|
170 |
} |
|
171 |
||
172 |
static String byte16HexString(int id) { |
|
173 |
return "0x" + |
|
174 |
hexDigits[(id >> 12) & 0x0F] + hexDigits[(id >> 8) & 0x0F] + |
|
175 |
hexDigits[(id >> 4) & 0x0F] + hexDigits[id & 0x0F]; |
|
176 |
} |
|
177 |
||
178 |
static String toHexString(byte[] bytes) { |
|
179 |
if (bytes == null || bytes.length == 0) { |
|
180 |
return ""; |
|
181 |
} |
|
182 |
||
183 |
StringBuilder builder = new StringBuilder(bytes.length * 3); |
|
184 |
boolean isFirst = true; |
|
185 |
for (byte b : bytes) { |
|
186 |
if (isFirst) { |
|
187 |
isFirst = false; |
|
188 |
} else { |
|
189 |
builder.append(' '); |
|
190 |
} |
|
191 |
||
192 |
builder.append(hexDigits[(b >> 4) & 0x0F]); |
|
193 |
builder.append(hexDigits[b & 0x0F]); |
|
194 |
} |
|
195 |
return builder.toString(); |
|
196 |
} |
|
197 |
||
198 |
static String toHexString(long lv) { |
|
199 |
StringBuilder builder = new StringBuilder(128); |
|
200 |
||
201 |
boolean isFirst = true; |
|
202 |
do { |
|
203 |
if (isFirst) { |
|
204 |
isFirst = false; |
|
205 |
} else { |
|
206 |
builder.append(' '); |
|
207 |
} |
|
208 |
||
209 |
builder.append(hexDigits[(int)(lv & 0x0F)]); |
|
210 |
lv >>>= 4; |
|
211 |
builder.append(hexDigits[(int)(lv & 0x0F)]); |
|
212 |
lv >>>= 4; |
|
213 |
} while (lv != 0); |
|
214 |
builder.reverse(); |
|
215 |
||
216 |
return builder.toString(); |
|
217 |
} |
|
218 |
||
219 |
/** |
|
220 |
* Utility method to convert a BigInteger to a byte array in unsigned |
|
221 |
* format as needed in the handshake messages. BigInteger uses |
|
222 |
* 2's complement format, i.e. it prepends an extra zero if the MSB |
|
223 |
* is set. We remove that. |
|
224 |
*/ |
|
225 |
static byte[] toByteArray(BigInteger bi) { |
|
226 |
byte[] b = bi.toByteArray(); |
|
227 |
if ((b.length > 1) && (b[0] == 0)) { |
|
228 |
int n = b.length - 1; |
|
229 |
byte[] newarray = new byte[n]; |
|
230 |
System.arraycopy(b, 1, newarray, 0, n); |
|
231 |
b = newarray; |
|
232 |
} |
|
233 |
return b; |
|
234 |
} |
|
14194
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
diff
changeset
|
235 |
} |