ssl - 如何在 ehcache 中配置 RMI over SSL 进行复制

标签 ssl replication ehcache

我的 ehcache 复制在没有 SSL 支持的情况下也能正常工作。 我希望通过 SSL 支持我的 ehcache 复制,即我希望通过 SSL 进行 RMI

我怎样才能做到这一点?

这是我正在使用的手动对等发现示例。

<cacheManagerPeerProviderFactory
class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
properties="peerDiscovery=manual,
rmiUrls=//10.100.10.12:40002/ssoSessionStore"/> 

我可以为 RMI 调用提供一些 SSL 支持吗?

谢谢

最佳答案

我必须更改 ehcache 源代码并更改一些类来支持 SSL。当 ehcache 通过 rmi bootsup 时,它会在 rmiregistry 上注册自身。我需要通过 SSL 上下文启动此注册表

查看类 RMICacheManagerPeerListener.java 中的方法 startRegistry() 这是 RMI 注册表启动的主类。修改代码的人首先需要了解ehcache rmi代码流程。下面的代码是必须完成的操作以及分别更改其他方法的片段。

final String SSL= System.getProperty("isSSL");
  protected void startRegistry() throws RemoteException {
        try {
            LOG.info("Trying to Get Exsisting Registry =========>> ");
            if (SSL != null && SSL.equals("ssl"))
                registry = LocateRegistry.getRegistry(hostName, port.intValue(),
                        new SslRMIClientSocketFactory());
            else
                registry = LocateRegistry.getRegistry(port.intValue());
            try {
                registry.list();
            } catch (RemoteException e) {
                // may not be created. Let's create it.
                if (SSL != null && SSL.equals("ssl")) {
                    LOG.info("Registry not found, Creating New SSL =========>> ");
                    registry = LocateRegistry.createRegistry(port.intValue(),
                            new SslRMIClientSocketFactory(), new SslRMIServerSocketFactory(null, null, true));
                } else {
                    LOG.info("Registry not found, Creating New Naming registry =========>> ");
                    registry = LocateRegistry.createRegistry(port.intValue());
                }

                registryCreated = true;

            }
        } catch (ExportException exception) {
            LOG.error("Exception starting RMI registry. Error was " + exception.getMessage(), exception);
        }
    }

同样,我对方法进行了更改

bind()
notifyCacheAdded()
unbind()
disposeRMICachePeer()
populateListOfRemoteCachePeers()
bind()
init() 

关于ssl - 如何在 ehcache 中配置 RMI over SSL 进行复制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31117458/

相关文章:

ssl - jmeter 的动态证书使用

sql-server - 为什么 SQL Server 不允许在配置后恰好删除分发服务器?

Hadoop:是否可以避免某些文件的复制?

amazon-web-services - 文件上传的最长 Amazon S3 复制时间是多少?

java - 集合未从 hibernate/ehcache 二级缓存中读取

ssl - 无法使用 Let's Encrypt 证书通过 ldaps 连接到服务器

ssl - openssl 验证不使用 GeoTrust 证书

使用 AFNetworking 没有证书的 iOS SSL Pinning?

java - 为什么在 jvm 重启后 ehcache 磁盘存储失效?

java - 操作 Hibernate 二级缓存