Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
77f696cb
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
77f696cb
编写于
9月 01, 2016
作者:
C
coffeys
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8164846: CertificateException missing cause of underlying exception
Reviewed-by: xuelei
上级
be4d0ba8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
61 addition
and
34 deletion
+61
-34
src/share/classes/sun/security/ssl/SSLContextImpl.java
src/share/classes/sun/security/ssl/SSLContextImpl.java
+1
-1
test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLContextImpl/TrustTrustedCert.java
...net/ssl/internal/ssl/SSLContextImpl/TrustTrustedCert.java
+60
-33
未找到文件。
src/share/classes/sun/security/ssl/SSLContextImpl.java
浏览文件 @
77f696cb
...
...
@@ -1115,7 +1115,7 @@ final class AbstractTrustManagerWrapper extends X509ExtendedTrustManager
}
}
catch
(
CertPathValidatorException
cpve
)
{
throw
new
CertificateException
(
"Certificates do
es not conform to algorithm constraints"
);
"Certificates do
not conform to algorithm constraints"
,
cpve
);
}
}
}
...
...
test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLContextImpl/TrustTrustedCert.java
浏览文件 @
77f696cb
...
...
@@ -30,12 +30,13 @@
/*
* @test
* @bug 7113275
* @bug 7113275
8164846
* @summary compatibility issue with MD2 trust anchor and old X509TrustManager
* @run main/othervm TrustTrustedCert PKIX TLSv1.1
* @run main/othervm TrustTrustedCert SunX509 TLSv1.1
* @run main/othervm TrustTrustedCert PKIX TLSv1.2
* @run main/othervm TrustTrustedCert SunX509 TLSv1.2
* @run main/othervm TrustTrustedCert PKIX TLSv1.1 true
* @run main/othervm TrustTrustedCert PKIX TLSv1.1 false
* @run main/othervm TrustTrustedCert SunX509 TLSv1.1 false
* @run main/othervm TrustTrustedCert PKIX TLSv1.2 false
* @run main/othervm TrustTrustedCert SunX509 TLSv1.2 false
*/
import
java.net.*
;
...
...
@@ -181,23 +182,32 @@ public class TrustTrustedCert {
Thread
.
sleep
(
50
);
}
SSLContext
context
=
generateSSLContext
();
SSLSocketFactory
sslsf
=
context
.
getSocketFactory
();
SSLSocket
sslSocket
=
(
SSLSocket
)
sslsf
.
createSocket
(
"localhost"
,
serverPort
);
// enable the specified TLS protocol
sslSocket
.
setEnabledProtocols
(
new
String
[]
{
tlsProtocol
});
InputStream
sslIS
=
sslSocket
.
getInputStream
();
OutputStream
sslOS
=
sslSocket
.
getOutputStream
();
sslOS
.
write
(
'B'
);
sslOS
.
flush
();
sslIS
.
read
();
sslSocket
.
close
();
SSLSocket
sslSocket
=
null
;
try
{
SSLContext
context
=
generateSSLContext
();
SSLSocketFactory
sslsf
=
context
.
getSocketFactory
();
sslSocket
=
(
SSLSocket
)
sslsf
.
createSocket
(
"localhost"
,
serverPort
);
// enable the specified TLS protocol
sslSocket
.
setEnabledProtocols
(
new
String
[]
{
tlsProtocol
});
InputStream
sslIS
=
sslSocket
.
getInputStream
();
OutputStream
sslOS
=
sslSocket
.
getOutputStream
();
sslOS
.
write
(
'B'
);
sslOS
.
flush
();
sslIS
.
read
();
}
catch
(
SSLHandshakeException
e
)
{
// focus in on the CertPathValidatorException
Throwable
t
=
e
.
getCause
().
getCause
();
if
((
t
==
null
)
||
(
expectFail
&&
!
t
.
toString
().
contains
(
"MD5withRSA"
)))
{
throw
new
RuntimeException
(
"Expected to see MD5withRSA in exception output "
+
t
);
}
}
finally
{
if
(
sslSocket
!=
null
)
sslSocket
.
close
();
}
}
/*
...
...
@@ -206,10 +216,13 @@ public class TrustTrustedCert {
*/
private
static
String
tmAlgorithm
;
// trust manager
private
static
String
tlsProtocol
;
// trust manager
// set this flag to test context of CertificateException
private
static
boolean
expectFail
;
private
static
void
parseArguments
(
String
[]
args
)
{
tmAlgorithm
=
args
[
0
];
tlsProtocol
=
args
[
1
];
expectFail
=
Boolean
.
parseBoolean
(
args
[
2
]);
}
private
static
SSLContext
generateSSLContext
()
throws
Exception
{
...
...
@@ -232,7 +245,7 @@ public class TrustTrustedCert {
// generate the private key.
PKCS8EncodedKeySpec
priKeySpec
=
new
PKCS8EncodedKeySpec
(
Base64
.
getMimeDecoder
().
decode
(
targetPrivateKey
));
Base64
.
getMimeDecoder
().
decode
(
targetPrivateKey
));
KeyFactory
kf
=
KeyFactory
.
getInstance
(
"RSA"
);
RSAPrivateKey
priKey
=
(
RSAPrivateKey
)
kf
.
generatePrivate
(
priKeySpec
);
...
...
@@ -338,20 +351,25 @@ public class TrustTrustedCert {
volatile
Exception
clientException
=
null
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
// MD5 is used in this test case, don't disable MD5 algorithm.
Security
.
setProperty
(
"jdk.certpath.disabledAlgorithms"
,
/*
* Get the customized arguments.
*/
parseArguments
(
args
);
/*
* MD5 is used in this test case, don't disable MD5 algorithm.
* if expectFail is set, we're testing exception message
*/
if
(!
expectFail
)
{
Security
.
setProperty
(
"jdk.certpath.disabledAlgorithms"
,
"MD2, RSA keySize < 1024"
);
}
Security
.
setProperty
(
"jdk.tls.disabledAlgorithms"
,
"SSLv3, RC4, DH keySize < 768"
);
if
(
debug
)
System
.
setProperty
(
"javax.net.debug"
,
"all"
);
/*
* Get the customized arguments.
*/
parseArguments
(
args
);
/*
* Start the tests.
*/
...
...
@@ -376,7 +394,8 @@ public class TrustTrustedCert {
startServer
(
false
);
}
}
catch
(
Exception
e
)
{
// swallow for now. Show later
System
.
out
.
println
(
"Unexpected exception: "
);
e
.
printStackTrace
();
}
/*
...
...
@@ -440,7 +459,11 @@ public class TrustTrustedCert {
*/
System
.
err
.
println
(
"Server died..."
);
serverReady
=
true
;
serverException
=
e
;
if
(!
expectFail
)
{
// only record if we weren't expecting.
// client side will record exception
serverException
=
e
;
}
}
}
};
...
...
@@ -449,7 +472,11 @@ public class TrustTrustedCert {
try
{
doServerSide
();
}
catch
(
Exception
e
)
{
serverException
=
e
;
// only record if we weren't expecting.
// client side will record exception
if
(!
expectFail
)
{
serverException
=
e
;
}
}
finally
{
serverReady
=
true
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录