[英]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.