连接到JDBC MS SQL Server时,证书不符合算法约束

时间:2016-12-19 22:48:04

标签: java sql-server spring jdbc

我正在尝试将我的Spring应用程序连接到Microsoft SQL Server数据库但是我收到以下错误:

Request processing failed; nested exception is org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection] with root cause
 java.security.cert.CertificateException: Certificates does not conform to algorithm constraints

我已尝试将 JDK的certpath 设置删除为空白,如:jdk.certpath.disabledAlgorithms=

这是我的配置:

@Configuration
@EnableJpaRepositories("com.abc.cet.eai.repository.sql")
@PropertySource("classpath:eai.application.properties")
public class JpaConfig {

    @Bean
    public DataSource dataSource() {
        SQLServerDataSource dataSource = new SQLServerDataSource();
        dataSource.setServerName("SERVERNAME");
        dataSource.setUser("USERNAME");
        dataSource.setPassword("PASSWORD");
        dataSource.setDatabaseName("DATABASE_NAME");
        return dataSource;
    }

    @Bean
    public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
        LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
        factory.setPackagesToScan("com.abc.cet.eai.domain");
        factory.setDataSource(dataSource());
        JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
        factory.setJpaVendorAdapter(vendorAdapter);
        factory.setJpaProperties(additionalProperties());

        return factory;
    }

    @Bean
    public PlatformTransactionManager transactionManager() {
        JpaTransactionManager txManager = new JpaTransactionManager();
        txManager.setEntityManagerFactory(entityManagerFactory().getObject());
        return txManager;
    }

    public Properties additionalProperties() {
        Properties properties = new Properties();
        properties.setProperty("hibernate.dialect", "org.hibernate.dialect.SQLServer2008Dialect");
        return properties;
    }
}

有没有人解决过类似的问题?

1 个答案:

答案 0 :(得分:0)

您基本上遇到的问题与我在WAGON-470中遇到的问题相同。使用MD5创建的证书被现代Java拒绝。您应该检查证书本身,服务器提供的密码并启用JSSE调试选项。您可能需要使用更安全的方法(如SHA256)更新/交换证书。