Link 个带有 https 来源的图片
Link images with https source
当我尝试将图像添加到 orbeon 表单时,我发现在某些情况下可以正常工作,而在其他情况下则不能。
例如,一个简单的代码,其表单使用 URL 的远程图像:
<xh:html xmlns:xh="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xxi="http://orbeon.org/oxf/xml/xinclude"
xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
xmlns:exf="http://www.exforms.org/exf/1-0"
xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
xmlns:saxon="http://saxon.sf.net/"
xmlns:sql="http://orbeon.org/oxf/xml/sql"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:fb="http://orbeon.org/oxf/xml/form-builder">
<xh:head>
<xh:title>Form with Image by URL</xh:title>
<xf:model id="fr-form-model" xxf:expose-xpath-types="true">
<!-- Main instance -->
<xf:instance id="fr-form-instance" xxf:exclude-result-prefixes="#all">
<form>
<section-1>
<control-3>http://media2.giphy.com/avatars/aap/gjQXEptJHq99.gif</control-3>
</section-1>
</form>
</xf:instance>
<!-- Bindings -->
<xf:bind id="fr-form-binds" ref="instance('fr-form-instance')">
<xf:bind id="section-1-bind" name="section-1" ref="section-1">
<xf:bind id="control-3-bind" ref="control-3" name="control-3" type="xf:anyURI"/>
</xf:bind>
</xf:bind>
<!-- Metadata -->
<xf:instance xxf:readonly="true" id="fr-form-metadata" xxf:exclude-result-prefixes="#all">
<metadata>
<application-name>UrlImage</application-name>
<form-name>UrlImage</form-name>
<title xml:lang="en">Form with Image by URL</title>
<description xml:lang="en"/>
<singleton>false</singleton>
</metadata>
</xf:instance>
<!-- Attachments -->
<xf:instance id="fr-form-attachments" xxf:exclude-result-prefixes="#all">
<attachments>
<css mediatype="text/css" filename="" size=""/>
<pdf mediatype="application/pdf" filename="" size=""/>
</attachments>
</xf:instance>
<!-- All form resources -->
<!-- Don't make readonly by default in case a service modifies the resources -->
<xf:instance id="fr-form-resources" xxf:readonly="false" xxf:exclude-result-prefixes="#all">
<resources>
<resource xml:lang="en">
<section-1>
<label>Untitled Section</label>
</section-1>
<control-3>
<label>This is a remote image</label>
</control-3>
</resource>
</resources>
</xf:instance>
<!-- Utility instances for services -->
<xf:instance id="fr-service-request-instance" xxf:exclude-result-prefixes="#all">
<request/>
</xf:instance>
<xf:instance id="fr-service-response-instance" xxf:exclude-result-prefixes="#all">
<response/>
</xf:instance>
</xf:model>
</xh:head>
<xh:body>
<fr:view>
<fr:body xmlns:xbl="http://www.w3.org/ns/xbl"
xmlns:oxf="http://www.orbeon.com/oxf/processors"
xmlns:p="http://www.orbeon.com/oxf/pipeline">
<fr:section id="section-1-control" bind="section-1-bind">
<xf:label ref="$form-resources/section-1/label"/>
<fr:grid>
<xh:tr>
<xh:td>
<xf:output id="control-3-control" bind="control-3-bind" mediatype="image/*">
<xf:label ref="$form-resources/control-3/label"/>
<!-- No hint? -->
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</xf:output>
</xh:td>
</xh:tr>
</fr:grid>
</fr:section>
</fr:body>
</fr:view>
</xh:body>
</xh:html>
重要的部分是 URL http://media2.giphy.com/avatars/aap/gjQXEptJHq99.gif
,它工作正常。但是如果你使用像https://media2.giphy.com/avatars/aap/gjQXEptJHq99.gif
这样的安全连接是无法获取图像的。
我不确定,也许问题与这个类似
这是可以被配置覆盖的东西吗?
我可以通过使用来自 https 站点的 URL 来使用图像,而无需为我的 java 商店中的每个服务器添加证书吗?
有properties配置,但你必须小心,因为通常你真的不应该信任所有证书!
例如,您的 https://media2.giphy.com/avatars/aap/gjQXEptJHq99.gif 示例可以在 Chrome 中运行而不会出现警告或错误,因此我希望它也可以在 JVM 中运行。也许 JVM 没有配置与浏览器相同的 CA 集。在这种情况下,JVM 可以配置为添加一些,尽管这有点棘手。
可能这种行为是由于 Orbeon 不直接使用图像 URL,在 Orbeon "server-media" 中进行了中间处理。
好的,看来最后,只有我将证书添加到 oxf.http.ssl.keystore.uri
中定义的 orbeon 的密钥库中,它才有效。但这仅在我知道将 link 编辑图像的服务器时才有效。不是 link 来自任何服务器的任何图像的有效解决方案。 Java 允许禁用此行为。在 Orbeon 有可能吗?
当我尝试将图像添加到 orbeon 表单时,我发现在某些情况下可以正常工作,而在其他情况下则不能。
例如,一个简单的代码,其表单使用 URL 的远程图像:
<xh:html xmlns:xh="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xxi="http://orbeon.org/oxf/xml/xinclude"
xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
xmlns:exf="http://www.exforms.org/exf/1-0"
xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
xmlns:saxon="http://saxon.sf.net/"
xmlns:sql="http://orbeon.org/oxf/xml/sql"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:fb="http://orbeon.org/oxf/xml/form-builder">
<xh:head>
<xh:title>Form with Image by URL</xh:title>
<xf:model id="fr-form-model" xxf:expose-xpath-types="true">
<!-- Main instance -->
<xf:instance id="fr-form-instance" xxf:exclude-result-prefixes="#all">
<form>
<section-1>
<control-3>http://media2.giphy.com/avatars/aap/gjQXEptJHq99.gif</control-3>
</section-1>
</form>
</xf:instance>
<!-- Bindings -->
<xf:bind id="fr-form-binds" ref="instance('fr-form-instance')">
<xf:bind id="section-1-bind" name="section-1" ref="section-1">
<xf:bind id="control-3-bind" ref="control-3" name="control-3" type="xf:anyURI"/>
</xf:bind>
</xf:bind>
<!-- Metadata -->
<xf:instance xxf:readonly="true" id="fr-form-metadata" xxf:exclude-result-prefixes="#all">
<metadata>
<application-name>UrlImage</application-name>
<form-name>UrlImage</form-name>
<title xml:lang="en">Form with Image by URL</title>
<description xml:lang="en"/>
<singleton>false</singleton>
</metadata>
</xf:instance>
<!-- Attachments -->
<xf:instance id="fr-form-attachments" xxf:exclude-result-prefixes="#all">
<attachments>
<css mediatype="text/css" filename="" size=""/>
<pdf mediatype="application/pdf" filename="" size=""/>
</attachments>
</xf:instance>
<!-- All form resources -->
<!-- Don't make readonly by default in case a service modifies the resources -->
<xf:instance id="fr-form-resources" xxf:readonly="false" xxf:exclude-result-prefixes="#all">
<resources>
<resource xml:lang="en">
<section-1>
<label>Untitled Section</label>
</section-1>
<control-3>
<label>This is a remote image</label>
</control-3>
</resource>
</resources>
</xf:instance>
<!-- Utility instances for services -->
<xf:instance id="fr-service-request-instance" xxf:exclude-result-prefixes="#all">
<request/>
</xf:instance>
<xf:instance id="fr-service-response-instance" xxf:exclude-result-prefixes="#all">
<response/>
</xf:instance>
</xf:model>
</xh:head>
<xh:body>
<fr:view>
<fr:body xmlns:xbl="http://www.w3.org/ns/xbl"
xmlns:oxf="http://www.orbeon.com/oxf/processors"
xmlns:p="http://www.orbeon.com/oxf/pipeline">
<fr:section id="section-1-control" bind="section-1-bind">
<xf:label ref="$form-resources/section-1/label"/>
<fr:grid>
<xh:tr>
<xh:td>
<xf:output id="control-3-control" bind="control-3-bind" mediatype="image/*">
<xf:label ref="$form-resources/control-3/label"/>
<!-- No hint? -->
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</xf:output>
</xh:td>
</xh:tr>
</fr:grid>
</fr:section>
</fr:body>
</fr:view>
</xh:body>
</xh:html>
重要的部分是 URL http://media2.giphy.com/avatars/aap/gjQXEptJHq99.gif
,它工作正常。但是如果你使用像https://media2.giphy.com/avatars/aap/gjQXEptJHq99.gif
这样的安全连接是无法获取图像的。
我不确定,也许问题与这个类似
这是可以被配置覆盖的东西吗? 我可以通过使用来自 https 站点的 URL 来使用图像,而无需为我的 java 商店中的每个服务器添加证书吗?
有properties配置,但你必须小心,因为通常你真的不应该信任所有证书!
例如,您的 https://media2.giphy.com/avatars/aap/gjQXEptJHq99.gif 示例可以在 Chrome 中运行而不会出现警告或错误,因此我希望它也可以在 JVM 中运行。也许 JVM 没有配置与浏览器相同的 CA 集。在这种情况下,JVM 可以配置为添加一些,尽管这有点棘手。
可能这种行为是由于 Orbeon 不直接使用图像 URL,在 Orbeon "server-media" 中进行了中间处理。
好的,看来最后,只有我将证书添加到 oxf.http.ssl.keystore.uri
中定义的 orbeon 的密钥库中,它才有效。但这仅在我知道将 link 编辑图像的服务器时才有效。不是 link 来自任何服务器的任何图像的有效解决方案。 Java 允许禁用此行为。在 Orbeon 有可能吗?