title: Get certificate out of default keystore of WebSphere Application Server 8.5.5
body: <p>I want to sign a SOAP message with a given certificate which is stored in the default keystore of my WebSphere Application Server (8.5.5).</p>
  
  <p>I'm refusing to provide a keystore path since the WebSphere should already know which keystores it has. And I would have to provide each path for each stage in our environments, which is what I wanted to prevent.</p>
  
  <p>My code looks like this to sign my message:</p>
  
  <pre><code>private void signEnvelope(final SOAPMessageContext context) {
      try {
          final Document doc = context.getMessage().getSOAPPart().getEnvelope().getOwnerDocument();
          final WSSecHeader header = new WSSecHeader();
          final Crypto crypto = CryptoFactory.getInstance(getCryptoProperties());
          header.insertSecurityHeader(doc);
  
          final WSSecTimestamp timestamp = new WSSecTimestamp();
          timestamp.build(doc, header);
  
          final WSSConfig config = WSSConfig.getNewInstance();
          config.setWsiBSPCompliant(false);
  
          final WSSecSignature signature = new WSSecSignature(config);
          signature.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
          signature.setUserInfo("certificateAlias", "keystorePassword");
          signature.setDigestAlgo(WSConstants.SHA256);
          signature.setSignatureAlgorithm("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256");
          signature.setParts(getSignatureParts());
          signature.setSigCanonicalization(WSConstants.C14N_EXCL_OMIT_COMMENTS);
          signature.build(doc, crypto, header);
      } catch (final Exception e) {
          LOG.error("Cannot sign message", e);
      }
  }
  
  private Properties getCryptoProperties() {
      final Properties props = new Properties();
      props.setProperty("org.apache.ws.security.crypto.provider", "org.apache.ws.security.components.crypto.Merlin");
      props.setProperty("org.apache.ws.security.crypto.merlin.keystore.type", "PKCS12");
      props.setProperty("org.apache.ws.security.crypto.merlin.keystore.file", "/home/wasadm/IBM/AppServer/profiles/server1/config/cells/mycell/nodes/mynode/key.p12");
      props.setProperty("org.apache.ws.security.crypto.merlin.keystore.alias", "myAlias");
      props.setProperty("org.apache.ws.security.crypto.merlin.keystore.password", "myKeystorePassword");
      return props;
  }
  
  private List&lt;WSEncryptionPart&gt; getSignatureParts() {
      final WSEncryptionPart[] parts = new WSEncryptionPart[] {
          new WSEncryptionPart(WSConstants.TIMESTAMP_TOKEN_LN, WSConstants.WSU_NS, "Element"),
          new WSEncryptionPart(WSConstants.ELEM_BODY, WSConstants.URI_SOAP11_ENV, "Element")
      };
  
      return new ArrayList&lt;WSEncryptionPart&gt;(Arrays.asList(parts));
  }
  </code></pre>
  
  <p>So, is it possible to just use the default keystore of WebSphere without providing an explicit path to this keystore?</p>