繁体   English   中英

如何通过自签名证书(使用Java keytool创建)将WS-Security添加到SOAP Web服务中?

[英]How do you add WS-Security to a SOAP web service with self signed certificates (created with Java keytool)?

方案:需要通信的两台计算机(!)(客户端,服务器)。

我想将WS-Security添加到(春季)SOAP Web服务。

我要添加此处描述的安全性: http : //docs.spring.io/spring-ws/docs/2.2.1.RELEASE/reference/htmlsingle/#security-xws-security-interceptor

如果我正确理解这一点,则必须生成(密钥)存储。

我不确定这是否正确,但我相信这些是必要的步骤:

  1. 在client-keystore.jks中创建一个自签名证书(= client-key-pair) (供客户端签署他的请求)

     keytool -genkey -alias client -keystore keystore.jks -storepass password -keyalg RSA -validity 360 -keysize 2048 
  2. 从client-keystore.jks中提取client-public-key.cer

     keytool -export -alias client -keystore client-keystore.jks -storepass password -file client-public-key.cer 
  3. 将客户端的clientpublickey.cer导入服务器的truststore.jks(用于验证客户端的请求签名)

     keytool -import -alias client -keystore client-keystore.jks -storepass password -file client-public-key.cer 

    现在,我可以接收来自客户端的签名请求了,对吗? 但是,在响应上签名呢?

  4. 在server-keystore.jks中创建第二个自签名证书(= server-key-pair) (供服务器对其响应签名)

     keytool -genkey -alias server -keystore server-keystore.jks -storepass password -keyalg RSA -validity 360 -keysize 2048 
  5. 从server-keystore.jks中提取server-public-key.cer

     keytool -export -alias server -keystore server-keystore.jks -storepass password -file server-public-key.cer 
  6. 将server-public-key.cer导入到client-truststore.jks中(用于验证服务器的响应签名)

     keytool -import -alias server -keystore client-truststore.jks -storepass password -file server-public-key.cer 

    最后,我有四个(密钥)存储,其中包含两个不同的证书:

    • 对于客户端:client-keystore( client-key-pair )和client-truststore( server-public-key
    • 对于服务器:服务器密钥库( server-key-pair )和服务器信任库( client-public-key

那是对的吗?

概括地说,您需要在服务器端创建一个证书颁发机构(CA)(使用openssl)。

然后,您在服务器端创建一个密钥库,它将用作您的信任库。 您将CA证书导入到此密钥库中。 此处详细描述了此过程:

https://gleichmann.wordpress.com/2009/01/29/ws-security-using-cert-authentication-with-spring-ws-iii-setting-up-the-security-infrastructure/

然后,您需要在客户端上创建密钥库,并生成证书签名请求(CSR)以发送到服务器以由CA进行签名。 然后,您将CA证书和签名证书(从CSR中获得)导入客户端密钥库。 再次,这在这里得到了很好的描述:

https://gleichmann.wordpress.com/2009/02/05/ws-security-using-cert-authentication-with-spring-ws-iv-how-to-set-up-your-clients-keystore/

因此,总而言之。 客户端和服务器上各有一个密钥库。 服务器上的自签名CA证书和客户端上的服务器CA签名的证书!

我所引用的系列文章共有5篇。 我不能高度推荐他们。

希望对您有所帮助!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM