【问题标题】:jclouds: how to supply own KeyStore when creating BlobStoreContextjclouds:创建 BlobStoreContext 时如何提供自己的 KeyStore
【发布时间】:2011-11-23 23:12:58
【问题描述】:

我有一个带有自签名证书的私有 blob 存储 (swift)。

我想将此商店与 jclouds 一起使用。现在,以下工作:

Properties overrides = new Properties();
overrides.setProperty(Constants.PROPERTY_ENDPOINT, "https://example.com:8080/auth");
overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true");
overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true");

BlobStoreContext context = new BlobStoreContextFactory().createContext("swift", 
    userCredentials.getIdent(), userCredentials.getSecret(), 
    ImmutableSet.<Module> of(), overrides);

但是,既然我有证书,有没有办法让这更安全并告诉 jclouds 使用该特定证书而不是信任任何证书?

我确实知道如何将证书加载到Certificate 对象中,并且我也知道如何使用证书创建KeyStore 对象。

我的问题是:如何让 jclouds 使用我的 CertificateKeyStore 进行证书验证?

【问题讨论】:

    标签: java https ssl-certificate jclouds


    【解决方案1】:

    目前,jclouds 不提供此挂钩,因此您必须修改 JRE 密钥库。随时在此处添加功能请求:http://code.google.com/p/jclouds/issues/entry

    【讨论】:

      【解决方案2】:

      正如 Adrian 在 jclouds-user 邮件列表中向我指出的那样,现在可以通过添加这样的模块:

      .modules(ImmutableSet.of(new AbstractModule(){
       @Override public void configure() {
        bind(new TypeLiteral<Supplier<SSLContext>>(){}).toInstance(new
         Supplier<SSLContext>() {
          @Override public SSLContext get() {
           return whatYouManage; // note this is called per-request so
                                 //can be expensive.
           }
        }
       }
      }))
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-02-05
        • 2014-03-15
        • 1970-01-01
        • 2011-07-14
        • 1970-01-01
        • 2015-04-05
        • 2017-12-07
        • 2014-09-27
        相关资源
        最近更新 更多