1

I am trying to invoke a SOAP webservice in my spring boot application using spring-ws with a keystore which has multiple certs. The configuration always defaults to single cert.

Sample code below:

Wss4jSecurityInterceptor wss4jSecurityInterceptor = new Wss4jSecurityInterceptor();

Merlin merlin = new Merlin();
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
InputStream inputStream = new FileInputStream(ResourceUtils.getFile(("keystore.jks")));
keyStore.load(inputStream, "tester".toCharArray());

merlin.setKeyStore(keyStore);
wss4jSecurityInterceptor.setSecurementSignatureCrypto(merlin);
wss4jSecurityInterceptor.setSecurementUsername("test");
wss4jSecurityInterceptor.setSecurementPassword("");

webServiceTemplate.setInterceptors(new org.springframework.ws.client.support.interceptor.ClientInterceptor[]
        {wss4jSecurityInterceptor});

When i checked the source code of the apache library class WSSecSignature class. I see there is a configuration for picking up multiple cert. But am not sure how to set the singleCert to be false in the wss4jSecurityInterceptor. It always goes to the else block in the below logic

if (!this.useSingleCert) {
    this.secRef.addTokenType("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509PKIPathv1");
    ref.setValueType("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509PKIPathv1");
} else {
    ref.setValueType("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3");
}

Is there a config i need to set while setting the keystore to Merin object, to make the useSingleCert as false?

Suria
  • 74
  • 4

1 Answers1

1

Found a work around to override the Wss4jSecurityInterceptor, set the property to false and use the extended interceptor

class SecurityInterceptor extends Wss4jSecurityInterceptor
{
    @Override
    protected RequestData initializeRequestData(MessageContext messageContext) {
        messageContext.setProperty(WSHandlerConstants.USE_SINGLE_CERTIFICATE, "false");
        return super.initializeRequestData(messageContext);
    }
    
}
Suria
  • 74
  • 4