【问题标题】:Accessing REST API in Apache Ignite Using HTTPS使用 HTTPS 在 Apache Ignite 中访问 REST API
【发布时间】:2020-04-30 07:45:54
【问题描述】:

我正在使用 Apache Ignite 2.8.0。 这是我的服务器配置,

<property name="sslContextFactory">
    <bean class="org.apache.ignite.ssl.SslContextFactory">
        <property name="keyStoreFilePath" value="C:\\ignite\\apache-ignite-2.8.0-bin\\keystore.jks"/>
        <property name="keyStorePassword" value="1234567"/>
        <property name="trustStoreFilePath" value="C:\\ignite\\\\apache-ignite-2.8.0-bin\\\\trust.jks"/>
        <property name="trustStorePassword" value="123456"/>
    </bean>
</property> 
<property name="connectorConfiguration">

              <bean class="org.apache.ignite.configuration.ConnectorConfiguration">

                    <property name="jettyPath" value="C:\apache-ignite-2.8.0-bin\examples\config\jetty-config.xml" />

              </bean>

        </property>

这是我的 jetty-config.xml, https://apacheignite.readme.io/docs/rest-api(复制粘贴)

它仍然只适用于 HTTP。它不适用于 HTTPS。我是怎么了? 如何在 Rest API 上启用 HTTPS?

【问题讨论】:

    标签: ssl https ignite rest


    【解决方案1】:

    很遗憾,documentation snippet 不完整。

    您还需要在 jetty 配置中定义 sslContextFactory

    <New id="sslContextFactory" class="org.eclipse.jetty.util.ssl.SslContextFactory">
        <Set name="keyStorePath">src/test/keystore/server.jks</Set>
        <Set name="keyStorePassword">123456</Set>
        <Set name="keyManagerPassword">123456</Set>
        <Set name="trustStorePath">src/test/keystore/trust-one.jks</Set>
        <Set name="trustStorePassword">123456</Set>
    </New>
    

    您还需要一个不同配置的连接器:

    <Call name="addConnector">
        <Arg>
            <New class="org.eclipse.jetty.server.ServerConnector">
                <Arg><Ref refid="Server"/></Arg>
                <Arg>
                    <Array type="org.eclipse.jetty.server.ConnectionFactory">
                        <Item>
                            <New class="org.eclipse.jetty.server.SslConnectionFactory">
                                <Arg><Ref refid="sslContextFactory"/></Arg>
                                <Arg>http/1.1</Arg>
                            </New>
                        </Item>
                        <Item>
                            <New class="org.eclipse.jetty.server.HttpConnectionFactory">
                                <Arg><Ref refid="httpCfg"/></Arg>
                            </New>
                        </Item>
                    </Array>
                </Arg>
      ...
    

    您还需要信任存储和签名的服务器密钥。生成那些,尤其是那些可能被网络浏览器接受的,超出了这个答案的范围。尝试让letsencrypt生成这些,也许。

    【讨论】:

    • 是的,它适用于 HTTPS。但我知道您与该站点的连接在我的浏览器中不安全。我该怎么办?
    • “生成可能被 Web 浏览器接受的证书超出了此答案的范围。也许可以尝试使用letsencrypt 生成这些证书。”
    • 其实我正在使用 python 来提供 https 请求。 import requests URL = "127.0.0.1:8080//ignite?cmd=version" r = requests.get(url = URL) print(r).......这给了我 SSL 错误
    • 尝试添加 verify=False stackoverflow.com/questions/15445981/…
    • 也许是因为你有双斜线?无论如何,获得 404 表明您走在正确的轨道上
    猜你喜欢
    • 1970-01-01
    • 2023-03-20
    • 1970-01-01
    • 2019-04-07
    • 2021-01-22
    • 1970-01-01
    • 2019-05-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多