简体   繁体   English

spring org.springframework.core.io.UrlResource不支持https资源

[英]spring org.springframework.core.io.UrlResource not support https resource

when config the grails config location as below 当配置grails的配置位置如下

grails.config.locations = [
    "https://ip:8443/config/Config.groovy"
]

will get the below warning message in log 将在日志中获得以下警告消息

 2018-11-28 19:04:22,682 WARN   ConfigurationHelper - Unable to load specified config location https://ip:8443/config/Config.groovy : File does not exist.

but I can access https://ip:8443/config/Config.groovy directly from the browser. 但我可以直接从浏览器访问https:// ip:8443 / config / Config.groovy

In org.codehaus.groovy.grails.commons.cfg.ConfigurationHelper.mergeInLocations() org.codehaus.groovy.grails.commons.cfg.ConfigurationHelper.mergeInLocations()中

private static void mergeInLocations(ConfigObject config, List locations, PathMatchingResourcePatternResolver resolver, ClassLoader classLoader) {

...
 def resource = resolver.getResource(location.toString())
 if(resource.exists()) {
      ...
 } else {
   LOG.warn "Unable to load specified config location $location : File does not exist."
 }

} }

the resolver is the org.springframework.core.io.support.PathMatchingResourcePatternResolver in spring. 解析器是春季的org.springframework.core.io.support.PathMatchingResourcePatternResolver and resolver.getResource(location.toString()) result will be a org.springframework.core.io.UrlResource 和resolver.getResource(location.toString())结果将是org.springframework.core.io.UrlResource

and UrlResource.exists() code is like 和UrlResource.exists()代码就像

public boolean exists() {
      ...
    try {
       URLConnection con = url.openConnection();
       HttpURLConnection httpCon =
                    (con instanceof HttpURLConnection ? (HttpURLConnection) con : null);
            if (httpCon != null) {
                int code = httpCon.getResponseCode();
                if (code == HttpURLConnection.HTTP_OK) {
                    return true;
                }
                else if (code == HttpURLConnection.HTTP_NOT_FOUND) {
                    return false;
                }
            }
    }catch(IOException ex){
       return false;
    }

}

and since its https , it will throw java.security.cert.CertificateException: No subject alternative names present when httpCon.getResponseCode(). 自从其https以来,它将抛出java.security.cert.CertificateException: httpCon.getResponseCode()时不存在使用者替代名称

so UrlResource is not for https resource? 所以UrlResource不是https资源吗? what should I do if I want to load the https resource? 如果要加载https资源,该怎么办? thanks. 谢谢。

Note the error message you describe, which I can also duplicate: "No subject alternative names present" means that your hostname "ip" is not in the certificate. 请注意您描述的错误消息,我也可以重复该错误消息:“不存在使用者替代名称”表示您的主机名“ ip”不在证书中。 Try switching to the fully qualified domain name, like "ip.mydomain.com" or whatever is encoded in the certificate. 尝试切换到完全限定的域名,例如“ ip.mydomain.com”或证书中编码的任何名称。 (You can view your certificate details in your browser on the "page info" dialog) (您可以在浏览器的“页面信息”对话框上查看证书的详细信息)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Spring 5.1 + Tomcat 9 + Java 10 +模块化项目= java.lang.NoClassDefFoundError:org / springframework / core / io / Resource - Spring 5.1 + Tomcat 9 + Java 10 + moduled project = java.lang.NoClassDefFoundError: org/springframework/core/io/Resource 如何处理Swagger Codegen的org.springframework.core.io.Resource - How to handle org.springframework.core.io.Resource for Swagger Codegen 如何模拟 org.springframework.core.io.Resource object? - How to mock org.springframework.core.io.Resource object? 实例化bean失败; 嵌套的异常是java.lang.NoClassDefFoundError:org / springframework / core / io / Resource-使用spring-core.4_2_5 - Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/core/io/Resource - using spring-core.4_2_5 java.lang.NoClassDefFoundError: org/springframework/core/io/Resource 异常 - java.lang.NoClassDefFoundError: org/springframework/core/io/Resource Exception java.lang.ClassNotFoundException: org.springframework.core.io.Resource - java.lang.ClassNotFoundException: org.springframework.core.io.Resource 为 org.springframework.core.io.Resource 对象分配名称 - Assigning name to a org.springframework.core.io.Resource object 无法将联系人投射到org.springframework.core.io.support.ResourceRegion - Contact cannot be cast to org.springframework.core.io.support.ResourceRegion org.springframework.web.multipart.MultipartFile 和 org.springframework.core.io.Resource 之间的转换 - Conversion between org.springframework.web.multipart.MultipartFile and org.springframework.core.io.Resource 如何修复 Spring Tool Suite 中的“线程“main”中的异常 java.lang.NoClassDefFoundError: org/springframework/core/io/support/SpringFactoriesLoader” - How to fix "Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/core/io/support/SpringFactoriesLoader" in Spring Tool Suite
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM