无法将java spring启动应用程序连接到amazon密钥空间

xxls0lw8  于 2021-07-26  发布在  Java
关注(0)|答案(1)|浏览(1085)

我正在尝试将我的javaspring启动应用程序连接到aws键空间。我关注了amazons文档,了解了如何使用apachecassandra的datastax java驱动程序来设置和配置这个连接(https://docs.aws.amazon.com/keyspaces/latest/devguide/using_java_driver.html). 我还研究了以下内容:
不支持带有amazon键空间的分区器(对于apache cassandra)
通过springReact式数据自动配置连接到aws密钥空间
https://docs.spring.io/spring-data/cassandra/docs/3.2.0/reference/html/#cassandra.connectors
以下是我收到的错误:
org.springframework.beans.factory.beancreationexception:创建名为“cassandrasession”的bean时出错,该bean在类路径资源[com/envase/connect/config/cassandrasetup.class]中定义:调用init方法失败;嵌套的异常是com.datastax.oss.driver.api.core.allnodesfailedexception:无法到达任何联系点,请确保提供了有效的地址(显示前1个节点,有关详细信息,请使用getallerrors()):node(endpoint=cassandra.us-east-2.amazonaws。com:9142,hostid=null,hashcode=3fcfeaa9):[com.datastax.oss.driver.api.core.drivertimeoutexception:[s5 | control | id:0x19776100,l:/192.168.1.105:53683-r:cassandra.us-east-2.amazonaws.com/3.12.23.181:9142]协议初始化请求,步骤1(选项):在org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.initializebean(abstractautowirecapablebeanfactory)的5000毫秒后超时。java:1786)~[ Spring Bean -5.3.6。jar:5.3.6]在org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.docreatebean(abstractautowirecapablebeanfactory)。java:602)~[ Spring Bean -5.3.6。jar:5.3.6]位于org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.createbean(abstractautowirecapablebeanfactory)。java:524)~[ Spring Bean -5.3.6。jar:5.3.6]在org.springframework.beans.factory.support.abstractbeanfactory.lambda$dogetbean$0(abstractbeanfactory)。java:335)~[ Spring Bean -5.3.6。jar:5.3.6]位于org.springframework.beans.factory.support.defaultsingletonbeanregistry.getsingleton(defaultsingletonbeanregistry)。java:234)~[ Spring Bean -5.3.6。jar:5.3.6]在org.springframework.beans.factory.support.abstractbeanfactory.dogetbean(abstractbeanfactory)。java:333)~[ Spring Bean -5.3.6。jar:5.3.6]在org.springframework.beans.factory.support.abstractbeanfactory.getbean(abstractbeanfactory。java:208)~[ Spring Bean -5.3.6。jar:5.3.6]在org.springframework.beans.factory.config.dependencydescriptor.resolvecandidate(dependencydescriptor。java:276)~[ Spring Bean -5.3.6。jar:5.3.6]位于org.springframework.beans.factory.support.defaultlistablebeanfactory.doresolvedependency(defaultlistablebeanfactory)。java:1380)~[ Spring Bean -5.3.6。jar:5.3.6]在org.springframework.beans.factory.support.defaultlistablebeanfactory.resolvedependency(defaultlistablebeanfactory)。java:1300)~[ Spring Bean -5.3.6。jar:5.3.6]在org.springframework.beans.factory.support.constructorresolver.resolveautowiredargument(constructorresolver。java:887)~[ Spring Bean -5.3.6。jar:5.3.6]在org.springframework.beans.factory.support.constructorresolver.createargumentarray(constructorresolver。java:791)~[ Spring Bean -5.3.6。jar:5.3.6] ... 25常见帧被忽略,原因是:com.datastax.oss.driver.api.core.allnodesfailedexception:无法到达任何联系点,请确保提供了有效地址(显示前1个节点,使用getallerrors()了解更多信息):node(endpoint=cassandra.us-east-2.amazonaws。com:9142,hostid=null,hashcode=3fcfeaa9):[com.datastax.oss.driver.api.core.drivertimeoutexception:[s5 | control | id:0x19776100,l:/192.168.1.105:53683-r:cassandra.us-east-2.amazonaws.com/3.12.23.181:9142]协议初始化请求,步骤1(选项):在com.datastax.oss.driver.api.core.allnodesfailedexception.copy(allnodesfailedexception)的[5000 ms]后超时。java:141)~[java-driver-core-4.8.0。jar:na]位于com.datastax.oss.driver.internal.core.util.concurrent.completablefutures.getunterruptibly(completablefutures)。java:149)~[java-driver-core-4.8.0。jar:na]在com.datastax.oss.driver.api.core.session.sessionbuilder.build(sessionbuilder。java:674)~[java-driver-core-4.8.0。jar:na]位于org.springframework.data.cassandra.config.cqlsessionfactorybean.buildsystemsession(cqlsessionfactorybean)。java:498)~[spring-data-cassandra-3.1.8。jar:3.1.8]在org.springframework.data.cassandra.config.cqlsessionfactorybean.afterpropertiesset(cqlsessionfactorybean)。java:451)~[spring-data-cassandra-3.1.8。jar:3.1.8]位于org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.invokeinitmethods(abstractautowirecapablebeanfactory)。java:1845)~[ Spring Bean -5.3.6。jar:5.3.6]在org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.initializebean(abstractautowirecapablebeanfactory)。java:1782)~[ Spring Bean -5.3.6。jar:5.3.6] ... 36个公共帧:com.datastax.oss.driver.api.core.drivertimeoutexception:[s5 | control | id:0x19776100,l:/192.168.1.105:53683-r:cassandra.us-east-2.amazonaws.com/3.12.23.181:9142]协议初始化请求,步骤1(选项):在com.datastax.oss.driver.internal.core.channel.channelhandlerrequest.ontimeout(channelhandlerrequest)5000毫秒后超时。java:108)~[java-driver-core-4.8.0。jar:na]
它还会反复打印以下警告,直到抛出上述错误:
2021-04-27 15:04:48.106警告17664---[s4-admin-0]c.d.o.d.internal.core.pool.channelpool:[s4 |/3.12.23.155:9142]打开新通道时出错(connectioninitexception:[s4 | id:0x0e9e0986,l:/192.168.1.105:53764-r:3.12.23.155/3.12.23.155:9142]协议初始化请求,步骤1(启动{cql\U版本=3.0.0,驱动程序\u name=datastax apache cassandra(r)的java驱动程序,驱动程序\u version=4.8.0,客户端\u id=f943143d-48b5-40ce-9d3c-f12123f3d687}):发送请求失败(javax.net.ssl.sslhandshakeexception:未找到与ip地址3.12.23.155匹配的主题替代名称)
内部版本.gradle:

plugins {
    id 'org.springframework.boot' version '2.4.5'
    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
    id 'java'
}

group = 'com.envase.connect'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-actuator'
    implementation 'org.springframework.boot:spring-boot-starter-security'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation group: 'com.datastax.oss', name: 'java-driver-core', version: '4.8.0'
    implementation group: 'com.datastax.oss', name: 'java-driver-query-builder', version: '4.8.0'
    implementation group: 'com.datastax.oss', name: 'java-driver-mapper-runtime', version: '4.8.0'
    implementation group: 'org.springframework.boot', name: 'spring-boot-starter-data-cassandra-reactive', version: '2.4.5'

对于com.datastax.oss依赖项,我也尝试了版本4.9.0和4.11.0
应用程序.conf

datastax-java-driver {
     basic.contact-points = ["cassandra.us-east-2.amazonaws.com:9142"]
     advanced.auth-provider {
         class = PlainTextAuthProvider
         username = "******"
         password = "******"
     }
     basic.load-balancing-policy {
         local-datacenter = "us-east-2"
     }
     advanced.connection {
         timeout = 30 seconds
         connect-timeout = 30 seconds
         init-query-timeout = 30 seconds
      }

     advanced.metadata {
         schema.enabled = "false"
         token-map.enabled = "false"
     }

     advanced.ssl-engine-factory {
         class = DefaultSslEngineFactory
         cipher-suites = [ "TLS_RSA_WITH_AES_128_CBC_SHA", "TLS_RSA_WITH_AES_256_CBC_SHA" ]
         truststore-path = "./src/main/resources/cassandra_truststore.jks"
         truststore-password = "****"
     }
 }

cassandra配置类:

import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.config.DriverConfigLoader;
import com.datastax.oss.driver.internal.core.config.typesafe.DefaultDriverConfigLoader;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.cassandra.config.AbstractReactiveCassandraConfiguration;
import org.springframework.data.cassandra.config.SchemaAction;
import org.springframework.data.cassandra.repository.config.EnableReactiveCassandraRepositories;

@Configuration
@EnableReactiveCassandraRepositories
public class CassandraSetup extends AbstractReactiveCassandraConfiguration {

  @Value("${cassandra.contact-points}")
  private String contactPoints;

  @Value("${cassandra.port}")
  private int port;

  @Value("${cassandra.keyspace}")
  private String keyspace;

  @Value("${cassandra.data.local-datacenter}")
  private String dataCenter;

  @Override
  protected String getKeyspaceName() {
    return keyspace;
  }

  @Override
  protected String getContactPoints() {
    return contactPoints;
  }

  @Override
  protected int getPort() {
    return port;
  }

  @Override
  public SchemaAction getSchemaAction() {
    return SchemaAction.NONE;
  }

    @Override
    protected CqlSession getRequiredSession() {
        DriverConfigLoader loader = DriverConfigLoader.fromClasspath("application.conf");
        return CqlSession.builder().withConfigLoader(loader).withLocalDatacenter(dataCenter).build();
    }
}

不管我怎么尝试,我还是不断地犯同样的错误。任何帮助都将不胜感激。

u2nhd7ah

u2nhd7ah1#

问题看起来与您正在使用的证书有关
这就是线索: "javax.net.ssl.SSLHandshakeException: No subject alternative names matching IP address 3.12.23.15" 检查这个:java certificateexception“没有与ip地址匹配的主题可选名称。。。“找到”

相关问题