java.lang.IllegalArgumentException:parseAlgParameters失败:ObjectIdentifier()--数据不是对象ID(标签= 48)

Mas*_*aik 5 java spring spring-security ssl-certificate spring-boot

在我的一台 AWS EC2 服务器中,我部署了三项服务 [Auth、orders、Security]。我为三个服务配置了 SSL,三个服务的 SSL 是相同的,身份验证命令服务在进行一些调整后工作正常,但安全服务有“java.lang.IllegalArgumentException:parseAlgParameters failed:ObjectIdentifier() - 数据不是” t 对象 ID (tag = 48)' 问题。我的服务器有以下Java 版本: openjdk 版本“ 1.8.0_302 ” OpenJDK 运行时环境(版本 1.8.0_302-b08) OpenJDK 64 位服务器 VM(版本 25.302-b08,混合模式) 我从 Windows PC 部署了 jar 文件,对于我的 Windows PC,所有三个服务都工作正常。但这是我的 AWS Centos 服务器的问题。

最初,我使用 Openssl3 将 .crt 文件转换为 .p12,当时我的所有三个服务都存在上述问题。因此将我的 OpenSSL 降级到 1.1.1 版本。然后将我的 jar 构建到 AWS。这样“Auth”和“Order”服务就开始工作了。但我的安全服务仍然存在问题。下面是用于身份验证的 pom.xml。

    <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.2.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.lc.auth</groupId>
    <artifactId>AuthenticationService</artifactId>
    <version>MVP-V2.0.0</version>
    <name>AuthenticationService</name>
    <description>Authentication Service</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-rest</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>

            
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web-services</artifactId>
        </dependency>

        
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
            <version>8.0.11</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- https://mvnrepository.com/artifact/log4j/log4j -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>





        <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.11</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-test</artifactId>
            <scope>test</scope>
        </dependency>

    <dependency>
    <groupId>commons-io</groupId>
    <artifactId>commons-io</artifactId>
    <version>2.4</version>
</dependency>   

<!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-oauth2-jose -->
<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-oauth2-jose</artifactId>
    <version>5.2.3.RELEASE</version>
     <exclusions>
        <exclusion>
            <groupId>com.nimbusds</groupId>
            <artifactId>nimbus-jose-jwt</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<!-- https://mvnrepository.com/artifact/com.nimbusds/nimbus-jose-jwt -->
<dependency>
    <groupId>com.nimbusds</groupId>
    <artifactId>nimbus-jose-jwt</artifactId>
    <version>7.9</version>
</dependency>
<dependency>
    <groupId>org.imgscalr</groupId>
    <artifactId>imgscalr-lib</artifactId>
    <version>4.2</version>
</dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>
Run Code Online (Sandbox Code Playgroud)

下面是 Auth application.properties 文件

server.port=8282
server.ssl.enabled=true
server.ssl.key-store: classpath:localhost.p12
server.ssl.key-store-password: XXXXXX08
server.ssl.keyStoreType: PKCS12




spring.datasource.url=jdbc:ipaddr:3306/db_authentications?useSSL=false
spring.datasource.username=admin
spring.datasource.password=xxxx


spring.data.jdbc.repositories.enabled=false
spring.jpa.properties.hibernate.order_inserts=true

spring.datasource.max-active=100 # advanced configuration...
spring.datasource.max-idle=100
spring.datasource.min-idle=8
spring.jpa.hibernate.use-new-id-generator-mappings=false

spring.jpa.show-sql=false
spring.jpa.open-in-view=false


logging.level.org.springframework.web: DEBUG
logging.level.org.hibernate: ERROR


spring.main.banner-mode=off


#server.undertow.accesslog.enabled=true
#server.undertow.accesslog.dir=target/logs
#server.undertow.accesslog.pattern=combined
#server.compression.enabled=true
#server.compression.min-response-size=1



# Enable response compression
server.compression.enabled=true

# The comma-separated list of mime types that should be compressed
server.compression.mime-types=text/html,text/xml,text/plain,text/css,text/javascript,application/javascript,application/json

# Compress the response only if the response size is at least 1KB
server.compression.min-response-size=1000

# Enable HTTP/2 support, if the current environment supports it
server.http2.enabled=true

# Maximum time the response should be cached (in seconds) 
spring.resources.cache.cachecontrol.max-age=120

# The cache must re-validate stale resources with the server. Any expired resources must not be used without re-validating.
spring.resources.cache.cachecontrol.must-revalidate=true

# The resources are private and intended for a single user. They must not be stored by a shared cache (e.g CDN).
spring.resources.cache.cachecontrol.cache-private= false 

# The resources are public and any cache may store the response.
spring.resources.cache.cachecontrol.cache-public= true 

spring.servlet.multipart.enabled=true

# Write files to disk if the file size is more than 2KB.
spring.servlet.multipart.file-size-threshold=2KB

# The intermediate disk location where the uploaded files are written
spring.servlet.multipart.location=/tmp

# Maximum file size that can be uploaded
spring.servlet.multipart.max-file-size=50MB

# Maximum allowed multipart request size
spring.servlet.multipart.max-request-size=75MB

spring.task.execution.pool.keep-alive = 60s
server.undertow.always-set-keep-alive = false
Run Code Online (Sandbox Code Playgroud)

下面是安全服务pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.0.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.lc.inventory.security</groupId>
    <artifactId>LittleCarrotsInventorySecurityService</artifactId>
    <version>MVP-V2.0.0</version>
    <name>LittleCarrotsInventorySecurityService</name>
    <description>Little Carrots Inventory Security Service</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-rest</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <!-- 
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
-->

        </dependency>
        <!-- <dependency> -->
        <!-- <groupId>org.springframework.boot</groupId> -->
        <!-- <artifactId>spring-boot-starter-undertow</artifactId> -->
        <!-- </dependency> -->

        <!-- https://mvnrepository.com/artifact/io.undertow/undertow-core -->
        <!-- 
        <dependency>
            <groupId>io.undertow</groupId>
            <artifactId>undertow-core</artifactId>
            <version>2.2.0.Final</version>
        </dependency>
-->
        <!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
        
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>4.0.1</version>
            <scope>provided</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/io.undertow/undertow-servlet -->
        <!-- 
        <dependency>
            <groupId>io.undertow</groupId>
            <artifactId>undertow-servlet</artifactId>
            <version>2.2.0.Final</version>
        </dependency>
-->

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web-services</artifactId>
        </dependency>

        
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>


        <!-- https://mvnrepository.com/artifact/log4j/log4j -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>






        <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
            <version>3.2.0</version>
        </dependency>

        <dependency>
            <groupId>io.lettuce</groupId>
            <artifactId>lettuce-core</artifactId>
            <version>5.2.1.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.session</groupId>
            <artifactId>spring-session-core</artifactId>
        </dependency>


        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.11</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.4</version>
        </dependency>

<!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-oauth2-jose -->
<!-- https://mvnrepository.com/artifact/com.nimbusds/nimbus-jose-jwt -->
<dependency>
    <groupId>com.nimbusds</groupId>
    <artifactId>nimbus-jose-jwt</artifactId>
    <version>7.9</version>
</dependency>

    <!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
    <groupId>com.google.code.gson</groupId>
    <artifactId>gson</artifactId>
    <version>2.8.6</version>
</dependency>


        <dependency>
            <groupId>org.springframework.kafka</groupId>
            <artifactId>spring-kafka</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.kafka</groupId>
            <artifactId>spring-kafka-test</artifactId>
            <scope>test</scope>
        </dependency>
                <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>2.11.3</version>
</dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>
Run Code Online (Sandbox Code Playgroud)

下面是安全服务 application.properties 文件

server.port= 8443
server.ssl.enabled=true
server.ssl.key-store: classpath:localhost.p12
server.ssl.key-store-password: xxxxx
server.ssl.keyStoreType: PKCS12

spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration

spring.h2.console.enabled=true


#LIVE DB URLS ENABLE ON MAIN STREAM
spring.datasource.url=jdbc:mysql://ipadr:3306/main_securityservice?useSSL=false
spring.datasource.username=admin
spring.datasource.password=xxxx   



spring.data.jdbc.repositories.enabled=false
spring.jpa.properties.hibernate.order_inserts=true

spring.datasource.max-active=100 # advanced configuration...
spring.datasource.max-idle=100
spring.datasource.min-idle=8
spring.jpa.hibernate.use-new-id-generator-mappings=false

spring.jpa.show-sql=false
spring.jpa.open-in-view=false


logging.level.org.springframework.web: DEBUG
logging.level.org.hibernate: ERROR


spring.main.banner-mode=off



#server.undertow.accesslog.enabled=true
#server.undertow.accesslog.dir=target/logs
#server.undertow.accesslog.pattern=combined
#server.compression.enabled=true
#server.compression.min-response-size=1



# Enable response compression
server.compression.enabled=true

# The comma-separated list of mime types that should be compressed
server.compression.mime-types=text/html,text/xml,text/plain,text/css,text/javascript,application/javascript,application/json

# Compress the response only if the response size is at least 1KB
server.compression.min-response-size=1000

# Enable HTTP/2 support, if the current environment supports it
server.http2.enabled=true

# Maximum time the response should be cached (in seconds) 
spring.resources.cache.cachecontrol.max-age=120

# The cache must re-validate stale resources with the server. Any expired resources must not be used without re-validating.
spring.resources.cache.cachecontrol.must-revalidate=false

# The resources are private and intended for a single user. They must not be stored by a shared cache (e.g CDN).
spring.resources.cache.cachecontrol.cache-private= false 

# The resources are public and any cache may store the response.
spring.resources.cache.cachecontrol.cache-public= false 

spring.servlet.multipart.enabled=true

# Write files to disk if the file size is more than 2KB.
spring.servlet.multipart.file-size-threshold=2KB

# The intermediate disk location where the uploaded files are written
spring.servlet.multipart.location=/tmp

# Maximum file size that can be uploaded
spring.servlet.multipart.max-file-size=50MB

# Maximum allowed multipart request size
spring.servlet.multipart.max-request-size=75MB


spring.task.execution.pool.keep-alive = 60s
server.undertow.always-set-keep-alive = false

server.undertow.eager-filter-init=true
Run Code Online (Sandbox Code Playgroud)

在一些参考资料之后我也更新了 open jdk 但没有解决方案,下面是完整的异常详细信息。

org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat server
        at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:185) ~[s

小智 5

就我而言,它也发生在 jks 文件上。jks 文件由 Java-11 keytool 生成,并由 Java-8 使用。

我们需要使用 Java-8 keytool 重新创建 jks。


小智 0

也许您需要修复server.port=8282两个属性文件。确保两个文件中的一个82828443两个文件具有相同的端口。