java - 无法调用 DefaultBootstrap.bootstrap();自己的opensaml解组方法中的方法
问题描述
我编写了以下解组方法来处理我的 xml 文件,但在执行过程中遇到以下错误。
以下代码段是我的代码:
private Response a(String text) throws ConfigurationException, SAXException {
try {
DefaultBootstrap.bootstrap(); <= ERROR HERE
}
catch(ConfigurationException e) {
log.error("Error Encountered", e);
}
Schema s = SAMLSchemaBuilder.getSAML11Schema();
BasicParserPool bpp = new BasicParserPool();
bpp.setNamespaceAware(true);
bpp.setIgnoreElementContentWhitespace(true);
bpp.setSchema(schema);
InputStream is= new ByteArrayInputStream(Base64.decode(samlContent).getBytes());
Response res= null;
try {
Document doc = bpp.parse(is);
Element elmt= doc.getDocumentElement();
try {
QName qn = new QName(elmt.getNamespaceURI(), elmt.getLocalName(), elmt.getPrefix());
Unmarshaller um = Configuration.getUnmarshallerFactory().getUnmarshaller(qn);
samlResponse = (Response) unmarshaller.unmarshall(elmt);
} catch (XMLParserException e) {
logger.debug(e.getMessage());
} catch (UnmarshallingException e) {
logger.debug(e.getMessage());
}
return res;
}
以下是 IDE 中的错误消息返回:
java.lang.IllegalArgumentException: Error create SSL context
at org.opensaml.ws.soap.client.http.TLSProtocolSocketFactory.init(TLSProtocolSocketFactory.java:151)
at org.opensaml.ws.soap.client.http.TLSProtocolSocketFactory.<init>(TLSProtocolSocketFactory.java:111)
at org.opensaml.DefaultBootstrap.initializeHttpClient(DefaultBootstrap.java:118)
at org.opensaml.DefaultBootstrap.bootstrap(DefaultBootstrap.java:110)
如果您以前遇到以下问题,我将非常感谢任何形式的帮助或知识共享。谢谢!
解决方案
如果它只是一个测试代码,在没有任何 https 通信的情况下运行,你应该在 jvm 中设置系统属性 org.opensaml.httpclient.https.disableHostnameVerification=true,或者在 DefaultBootstrap.bootstrap() 方法之前包含以下代码片段:
System.setProperty("org.opensaml.httpclient.https.disableHostnameVerification", "true");
推荐阅读
- ssl - 使用 ssl 证书反应运行服务器
- javascript - 换行符不适用于追加
- laravel - 如何在数组 Laravel 中仅指定资源的方法
- python - 如何使用 Google Colab 在 Python 中执行此 POST 请求。我目前收到 400 响应代码
- api - Express API 发布请求中出现 401 未经授权的错误
- node.js - 护照身份验证和配置问题
- javascript - 关于 Google Apps 脚本 oAuth2 第三方验证码的问题
- android-studio - SimpleCursorAdapter + Picasso?
- ios - 如何从 Host App 共享 iMessage 应用程序或 URL?
- python - Scrapy Python 脚本给出了 raise TypeError("Cannot mix str and non-str arguments")