author | xuelei |
Wed, 05 Mar 2014 07:24:34 +0000 | |
changeset 23052 | 241885315119 |
parent 14342 | jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/AcceptLargeFragments.java@8435a30053c1 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
14342
8435a30053c1
7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents:
10328
diff
changeset
|
2 |
* Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5506 | 19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
2 | 22 |
*/ |
23 |
||
24 |
/* |
|
25 |
* @test |
|
26 |
* @bug 6388456 |
|
27 |
* @summary Need adjustable TLS max record size for interoperability |
|
28 |
* with non-compliant stacks |
|
10328 | 29 |
* @run main/othervm AcceptLargeFragments |
30 |
* |
|
31 |
* SunJSSE does not support dynamic system properties, no way to re-use |
|
32 |
* system properties in samevm/agentvm mode. |
|
2 | 33 |
* |
34 |
* Check the system property "jsse.SSLEngine.acceptLargeFragments" |
|
35 |
* |
|
36 |
* @author xuelei fan |
|
37 |
*/ |
|
38 |
||
39 |
import javax.net.ssl.SSLContext; |
|
40 |
import javax.net.ssl.SSLEngine; |
|
41 |
import javax.net.ssl.SSLSession; |
|
42 |
||
43 |
public class AcceptLargeFragments { |
|
44 |
public static void main (String[] args) throws Exception { |
|
45 |
SSLContext context = SSLContext.getDefault(); |
|
46 |
||
47 |
// set the property before initialization SSLEngine. |
|
48 |
System.setProperty("jsse.SSLEngine.acceptLargeFragments", "true"); |
|
49 |
||
50 |
SSLEngine cliEngine = context.createSSLEngine(); |
|
51 |
cliEngine.setUseClientMode(true); |
|
52 |
||
53 |
SSLEngine srvEngine = context.createSSLEngine(); |
|
54 |
srvEngine.setUseClientMode(false); |
|
55 |
||
56 |
SSLSession cliSession = cliEngine.getSession(); |
|
57 |
SSLSession srvSession = srvEngine.getSession(); |
|
58 |
||
59 |
// check packet buffer sizes. |
|
60 |
if (cliSession.getPacketBufferSize() < 33049 || |
|
61 |
srvSession.getPacketBufferSize() < 33049) { |
|
62 |
throw new Exception("Don't accept large SSL/TLS fragments"); |
|
63 |
} |
|
64 |
||
65 |
// check application data buffer sizes. |
|
66 |
if (cliSession.getApplicationBufferSize() < 32768 || |
|
67 |
srvSession.getApplicationBufferSize() < 32768) { |
|
68 |
throw new Exception( |
|
69 |
"Don't accept large SSL/TLS application data "); |
|
70 |
} |
|
71 |
} |
|
72 |
} |