Coder Social home page Coder Social logo

jmeter-wssecurity's Introduction

jmeter-wssecurity github-actions

Overview

Apache JMeter plugin for signing, encrypting and decrypting SOAP messages (WS-Security).

The plugin provides

  • Pre-Processors for adding digital signature or encryption to a sampler's payload (based on a certificate from a given keystore),
  • Pre-Processors for adding a Username Token or a Timestamp to a sampler's payload,
  • a Post-Processor for decrypting a sampler's response.

Supported are HTTP Request, JMS Publisher and JMS Point-to-Point samplers, SMTP and TCP sampler, as well as third party samplers that expose the payload via a JMeter StringProperty or a pair of getter/setter methods.

Installation

Under tab "Available Plugins", select "WS Security for SOAP", then click "Apply Changes and Restart JMeter".

Via Package from JMeter-Plugins.org

  1. Remove wss4j-*.jar and xmlsec-*.jar from JMeter's lib directory (if applicable).
  2. Download and extract the zip package into JMeter's lib directory.
  3. Restart JMeter.

Via Manual Download

  1. Copy the jmeter-wssecurity jar file into JMeter's lib/ext directory.
  2. Copy the following dependencies into JMeter's lib directory:
  3. Make sure to remove older versions of the above dependencies from the JMeter lib directory.
  4. Restart JMeter.

Usage

From the context menu, add the appropriate Pre or Post Processor to the test plan scope with the sampler containing the SOAP message.

The message to be signed or encrypted must be a valid SOAP message and must be in one of the following locations:

Note that the plugin does not assist with composing the message nor does it do any XML schema validation. Only the WS-Security header element will be inserted or modified. It is recommended to exclude the WS-Security header from the SOAP request and let the plugin generate it.

Users familiar with SoapUI will find similarities to the outgoing WS-Security configuration.

SOAP Message Signer

SOAP Message Signer

SOAP Message Encrypter

SOAP Message Encrypter

SOAP Message Username Token

SOAP Message Username Token

SOAP Message Timestamp

SOAP Message Timestamp

SOAP Message Decrypter

SOAP Message Decrypter

Configuration

Keystore Settings

The keystore file is expected to contain all keys referenced in the SOAP message headers that are required for signing and/or encrypting/decrypting.

The default keystore type is JCEKS (since v1.7, before Java platform default). Other keystore types can be used by defining the JMeter property jmeter.wssecurity.keystoreType (since v1.8), e.g. PKCS12, JKS, JCEKS.

Pre-Processors

The dropdown fields allow for the customization of most signature and encryption settings, depending on what the endpoint's WSDL defines.

โš ๏ธ Not all setting combinations are valid, and JMeter does not enforce a valid combination to be entered. Instead, invalid ones will cause errors to be logged during runtime.

Example: Key Identifier Type "Encrypted Key SHA1" is only valid for symmetric Signature Algorithms (HMAC).

Parts to Sign/Parts to Encrypt

These lists are empty by default, however, that results in the SOAP Body content to be signed or encrypted.

Suppose the Timestamp element was to be included in the signature or encryption in addition to the Body element, both would have to be listed as follows:

ID Name Namespace Encode
Body http://schemas.xmlsoap.org/soap/envelope/
Timestamp http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd

If there are multiple XML elements with the same name and namespace, the element's ID attribute can be used to determine which element is to be signed/encrypted. If the ID is specified, the Name and Namespace are not necessary and will not be used.

Example:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
        <element ID="e1">this should be encrypted</element>
        <element ID="e2">this is not to be encrypted</element>
        <element>another one</element>
    </soap:Body>
</soap:Envelope>
ID Name Namespace Encode
e1

Encode is only relevant for encryption (or attachments, see below) and can be one of the following:

  • "Element" (default): The entire XML element is encrypted.
  • "Content": Only child nodes of the XML element are encrypted (i.e. the element name and its attributes will remain in clear text).
  • "Header": Encloses the XML element in an EncryptedHeader element ("http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd"), but only if it is an immediate child node of the SOAP Header.

Post-Processor

The SOAP Message Decrypter takes a sampler's response data as input, expecting a SOAP message with WS-Security header, and decrypts the payload based on the content of a given keystore. This requires the private key password of the encryption certificate.

Until plugin version 1.6 this password is expected in the field "Private Key Password". As of version 1.7 it needs to be provided in the table Credentials for WSS Processing, along with the alias of the keystore entry.

Note: Due to the way the underlying wss4j library is implemented, any other, not encryption related security tokens in the response message will also be processed, for example signature tokens. Any such processing will fail if key information is not present. For example, should the response message include a symmetric signature token, the SOAP Message Decrypter needs the secret key that was used to generate the token.

The key(s) may be provided in the configured keystore, and the secret key password(s) can be listed in the table Credentials for WSS Processing. Likewise, if a response were to contain a Username Token, the password(s) for the expected username(s) can be listed in that table, so that the Post-Processor is able to validate the token.

Any WS-Security related exception encountered by the SOAP Message Decrypter while trying to decrypt or validate a response message will cause the sampler to fail and will create an assertion result, effectively behaving like an implicit assertion.

If this behaviour is not desired, it may be turned off via setting the JMeter property jmeter.wssecurity.failSamplerOnWSSException=false.

Support for 3rd party samplers

Samplers that are not JMeter core functionality, such as JMeter-Plugins, can also be used if they provide either a JMeter StringProperty or a public String getter/setter to access the sampler's payload with the SOAP message.

In that case, the JMeter property jmeter.wssecurity.samplerPayloadAccessors can be set to specify the class name and property name as in the following examples.

The SMTP Sampler stores the payload in the TestElement property "SMTPSampler.message". So, it would be configured for this plugin via jmeter.wssecurity.samplerPayloadAccessors=org.apache.jmeter.protocol.smtp.sampler.SmtpSampler."SMTPSampler.message". Note the quotes around the property name if it contains a dot.

Alternatively, if there is no such JMeter property, a Bean property can be used (without the get/set prefix), which the Pre-Processor will access at run time via Reflection.

Suppose a sampler like the following:

package some.package;
public class SomeSampler extends AbstractSampler {
	public String getPayload() 
	// ...
	public void setPayload(String content)
	// ...
}

Then the JMeter property should be set like so: jmeter.wssecurity.samplerPayloadAccessors=some.package.SomeSampler.payload

More than one of these can be comma separated (if really required).

Support for Attachments

SOAP Message Attachments can be digitally secured or validated/decrypted by the plugin. However, the attachment data must be explicitely provided and must match the attachment(s) transmitted by the sampler, i.e. the plugin is unable to automatically access samplers' attachments. To do this, the below lists (Attachments to Sign/Encrypt/Decrypt) have to be filled in with one row for each attachment.

Additionally, for SwA attachments, the special ID cid:Attachments needs to be added to the "Parts to Sign"/"Parts to Encrypt" (without Name or Namespace). The Encode column can be either:

  • "Element": The attachment content will be signed/encrypted as well as the MIME headers Content-Description, Content-Disposition, Content-ID, Content-Location, Content-Type.
  • "Content" (default): Only the attachment content will be signed/encrypted.

Attachments to Sign

An attachment is identified by its Content-ID (cid:) and consists of a sequence of bytes and (optionally) some headers. The following columns need to be populated accordingly:

  • Content-ID: The identifier attribute the attachment will be referenced by in the SOAP message.
  • Bytes: Base64-encoded content. This may come from anywhere, e.g. a file or a JMeter variable, and will typically be using some custom code snippet via the __groovy() function, such as ${__groovy(new File('secret.xml').bytes.encodeBase64())}
  • Headers: Newline-separated headers. Note: JMeter GUI fields do not allow newlines. Use ${__char(13)}.

Attachments to Encrypt

The Content-ID, Bytes and Headers columns have the same semantics as above.

After encrypting an attachment, the plugin can make the encrypted data available to the sampler for transmission. This can be done is a few different ways. The following columns determine how the plugin stores the output:

  • Output Mode: Defines how the encrypted attachment will be handed over to the sampler, and can be one of the following:
    • "File": Store encrypted bytes in a file (name and path as per "Output Destination" column)
    • "Variable": Assign encrypted bytes to JMeter object variable of type byte[] (variable name as per "Output Destination" column)
    • "Context": Store encrypted bytes in sampler context as object byte[] (context map key as per "Output Destination" column)
    • "Property": Assign encrypted bytes to a sampler ObjectProperty (property name as per "Output Destination" column)
    • "Base64": Assign encrypted bytes to JMeter variable as a base64-encoded String (variable name as per "Output Destination" column)
  • Output Destination: Name of the file/variable/property that will hold the encrypted attachment data.

Notes:

  • For Encode="Element" (Attachment-Complete as above), headers will be contained within the encrypted data. However, this plugin cannot modify the headers sent by the sampler, so the user needs to ensure that sensitive headers are removed from the attachment part.
  • The Content-Type header value may be required for the <xenc:EncryptedData> MimeType attribute as per processing rules, so the user needs to provide it in the Headers column.

Attachments to Decrypt

The plugin can also decrypt response attachments. They need to be listed as follows:

  • Content-ID: The Content-ID to tie the attachment back to a reference in the WSS header.
  • Bytes: Base64-encoded encrypted data from the sample response. This will most likely be retrieved by some custom code snippet via __groovy() accessing ctx.previousResult.subResults, depending on how the sampler handles response attachments. Example: ${__groovy(ctx.previousResult.subResults[0].responseData.encodeBase64())}

Note: If an attachment is referenced in the response's WSS header but not included in the "Attachments to Decrypt" list, response validation will fail.

The decrypted attachment content (and possibly headers) will be stored as a sub-sample of the main sample. The plugin will try to find a sub-sample that matches the attachment's Content-ID and if a match is found replace the sub-sample, or otherwise create a new sub-sample and add it to the main sample.

The search is done via recursively traversing all sub-samples (depth-first), and looking at either the sub-sample's Content-ID response header or the sub-sample's label. This can be configured via the JMeter property jmeter.wssecurity.findAttachmentsBySampleLabel:

  1. If undefined/empty, use the Content-ID response header for matching the attachment's cid.
  2. If defined/non-empty, use this regular expression's first capture group for matching the attachment's cid.

Example:

Suppose a sampler generates a main sample with an attachment sub-sample "somecontentid (text/xml)" but does not set the Content-ID header. Using the property value jmeter.wssecurity.findAttachmentsBySampleLabel=(.*) \(.*\) this sub-sample will be identified based on the first matcher group "somecontentid".

Troubleshooting

The signed or encrypted message payload can be inspected via "View Results Tree".

To avoid common problems, make sure that:

  • the Keystore contains an entry for the specified certificate alias,
  • the certificate and signature/encryption algorithms match,
  • the SOAP message is correctly formed and can be parsed,
  • Unlimited Strength JCE is installed to support all key lengths, etc.

It may be useful to increase the logging level in order to investigate any keystore or encryption related issues, for example by adding --loglevel=org.apache.wss4j=DEBUG to the JMeter command line.

It may also be helpful to inspect server side logs, especially for HTTP 500 type responses, unspecific SOAP Fault messages etc.

jmeter-wssecurity's People

Contributors

btmarkyou avatar dependabot[bot] avatar tilln avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

jmeter-wssecurity's Issues

Timestamp pre-processor not getting signed

Hello Guys

Im trying to work with the WS Security plugin but somehow cannot make that Timestamp to get it signed.

So far this is how I have the signer pre-procesor configuration:

image

And this is how the Timestamp pre-processor looks like:

image

But no luck, the message remains being sent with only the timestamp as non signed:

image

Appreciate any advice or whether this is some sort of defect...

Worth mention, I tried also getting rid of UsernameToken and Timestamp pre-processors and adding them as part of the initial request:

image

But same issue, just the Timestamp not getting signed...

How to handle <default> option in WSS outgoing Signature and Encryption sections

This plugin works well with the encryption and signer for various signature algorithm/canonicalization/digest algorithm in Signature and Symmetric encoding Algorithm/Key encryption algorithm in Encryption sections. when I tried to select , I couldnt get anything. When I edit and use on the Jmeter plugin for WSS, it is not working. Can you please provide me a solution to this. Thanks and your assistance is much appreciated.
image
image


Final request not signed

Hi, I tried to create a Test to send a SOAP request signed, but I get the error:

Invalid keystore format.

I am using:

  • JMeter 5.2.1
  • jmeter-wssecurity-1.7.jar
  • java version "1.8.0_261"

All of them running on Windows.

The Body data (before the Pre processor) is:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
        <SomeItem>
            <otherItem>
                <AnId>d1b32e62-7056-4edc-8c20-0cc033763c8a</AnId>
            </otherItem>
        </SomeItem>
    </s:Body>
</s:Envelope>

The request body (after the Pre processor) is:

<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Header>
        <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
            xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" s:mustUnderstand="1">
            <wsu:Timestamp wsu:Id="TS-bfd48433-89a0-4ede-9306-2e12ac883e69">
                <wsu:Created>2020-08-01T02:21:50.444Z</wsu:Created>
                <wsu:Expires>2020-08-01T02:26:50.444Z</wsu:Expires>
            </wsu:Timestamp>
        </wsse:Security>
    </s:Header>
    <s:Body>
        <SomeItem>
            <otherItem>
                <AnId>d1b32e62-7056-4edc-8c20-0cc033763c8a</AnId>
            </otherItem>
        </SomeItem>
    </s:Body>
</s:Envelope>

That is: The Signature node is not created!

I am using a Selfsigned certificate created with the ssl commands:

openssl genrsa 2048 > private.key
openssl req -new -x509 -nodes -sha1 -days 1000 -key private.key > public.cer
openssl pkcs12 -export -in public.cer -inkey private.key -out cert_key.p12

Then the .p12 file is stored in a jks file with:
keytool -importkeystore -srckeystore cert_key.p12 -srcstoretype PKCS12 -srcstorepass abc123 -keystore mykeystore.jks -storepass abc123

The configuration for the SOAP Message Signer is:

image

For better clarity I am attached the inputs used.

inputs.zip

saml2:Assertion

Hello,

I would like to a webservice using WSS security and saml2:Assertion , how could I do this using plugin, if this is not possible would you recommend me another plugin?

SOAP Message Decrypter: Failed

The SOAP-Message Decrypter do not decrypt, if the Sym Enc Algo is set to http://www.w3.org/2001/04/xmlenc#rsa-1_5.

The Decryption fail with and this was logged:

2018-11-16 15:44:14,656 DEBUG o.a.w.d.u.X509Util: Sym Enc Algo: http://www.w3.org/2001/04/xmlenc#rsa-1_5
2018-11-16 15:44:14,656 DEBUG o.a.w.d.p.EncryptedKeyProcessor: The Key transport method does not match the requirement
2018-11-16 15:44:14,656 ERROR n.c.b.j.m.AbstractWSSecurityPostProcessor: Processing failed! 

It cost much amount of time to discover, what is wrong (Checked keyStore, keyStore-Password, PrivateKeyPasswort many times).

My Research-Result was a update of ws4j changed from accepting by default RSA15KeyTransportAlogorith to deny this - but enabling is only possible by change the code (I found no hint for a property for enabling this).

So I ended in download your SourceCode and modfied this class:
nz.co.breakpoint.jmeter.modifiers.WSSDecryptionPostProcessor

requestData.setDecCrypto(getCrypto());
requestData.setSigVerCrypto(getCrypto());
requestData.setAllowRSA15KeyTransportAlgorithm(true); // <- Added these Line
WSHandlerResult results = secEngine.processSecurityHeader(document, requestData);
return document;

I think that there are three possible solution to solve this problem:

  1. allow the RSA15KeyTransportAlgorithm in the Decryption Post Processor
  2. Add an Log-Output at ERROR-Level for the first two Log-Entries AND remove the RSA15-Algorithm Option from the SOAP-Message-Encrypter (Field Key Encryption Algorithm). (If I can't decrypt RSA15 I should not have the possibility to encrypt with RSA15)
  3. Add an checkbox to the SOAP Message Decrypter to enable the RSA15-Algorithm and add an Log-Output at ERROR-Level for the first two Log-Entries.

Incorrect GUI layout

The rendering of the key identifier dropdown lists is wrong. It is placed in a separate property group for the encryption PP and the values are the same for both PPs.
This is not happening when loading a script during JMeter startup (that's why regression testing did not pick this up).

Webservice security version

Hi @tilln , Hope you are well.

Thanks for this awesome plugin. I am able to sign/encrypt the soap message with ease.

But what if the webservice uses a specific security version 'https://docs.microsoft.com/en-us/dotnet/api/system.servicemodel.messagesecurityversion?view=dotnet-plat-ext-6.0'. It works like a charm in loadrunner by selecting the correct security version. When it comes to jmeter, I couldnt find an option to select a similar security version. or java doesn't support something similar?

Any thoughts ?

Thanks,
Saviour

Clipboard operations not supported - Copy or Cut fails

Issue

Trying to copy or cut the Preprocessor in the JMeter UI currently fails as some internal objects are not serializable, e.g.
ERROR - jmeter.gui.action.Copy: Clipboard node read error:org.apache.xerces.jaxp.DocumentBuilderImpl java.io.NotSerializableException: org.apache.xerces.jaxp.DocumentBuilderImpl
...
at org.apache.jmeter.util.JMeterTreeNodeTransferable.setTransferData(JMeterTreeNodeTransferable.java:85) at org.apache.jmeter.gui.action.Copy.setCopiedNodes(Copy.java:119) at org.apache.jmeter.gui.action.Copy.doAction(Copy.java:66)
...
This means that parts of a JMeter Test Plan that contain the Preprocessor cannot be copied either.

Work-around

Use the "Duplicate" function inside the same JMeter instance and "Save Selection as"/"Merge" from one instance to another.

Fix

The Duplicate action uses the Test Element cloning mechanism and the Save/Merge just exports/imports configuration, however, the Copy Action needs to actually feed into the system clipboard, which it does via ObjectOutputStream which requires the JMeterTreeNode (i.e. the Preprocessor) to be Serializable.

Java code to implement just the SOAP message signer part of this plugin

Hi Tilln,

This plugin has been extremely useful to me and many others who use Jmeter to test signed soap requests. I tried looking at the source code but as I'm not an expert with java, couldn't really make out the logic or the code to accomplish just the 'soap message signer' part of this plugin. Reason for looking for this is, I am trying to do similar test in another tool which obviously can't use a jmeter plugin. I think if I pass on the soap packet and call a 'single java file', I would be able to successfully send a signed soap request just like what happens when we use this plugin in jmeter.

Thanks!

UTF-8 Encoding - Sampler parsing

I'm getting this error coming from my SOAP body request :

2017/06/09 12:09:35 ERROR - nz.co.breakpoint.jmeter.modifiers.AbstractWSSecurityPreProcessor: org.xml.sax.SAXParseException; lineNumber: 52; columnNumber: 93; Invalid byte 1 of 1-byte UTF-8 sequence.

Here's the line where it crashes

<sch:OrganizationBusinessActivityValue>Oilseed (except Soybean) Farmingย US</sch:OrganizationBusinessActivityValue>

I'm guessing the error is thrown at line 116 of the AbstractWSSecurityPreProcessor class

Document doc = docBuilder.parse(new ByteArrayInputStream(xml.getBytes()));

Possible fix :

Document doc = docBuilder.parse(new ByteArrayInputStream(xml.getBytes("UTF-8")));

Configure signature key and timestamp in jmeter

Hi am testing micro services using some authentication i. e. signature key and time stamp,now giving input in Header manager. It is valid only 5 minute .I am using input private key and signature generator jar in CMD .Could you pls share me any script for utomatic configuration in jmeter preprocessor.

WSM-00081: The X.509 certificate is not signed.

Hi, I am trying to use JMeter to test a Web Service which is deployed in Oracle Service Bus (OSB). The web service is secured using Oracle Web Services Manager (OWSM) policy "wss10_x509_token_with_message_protection_service_policy". I am testing the web service in two ways:
(a) using a Java client with OWSM client libraries. The client is configured to use the OWSM policy "wss10_x509_token_with_message_protection_client_policy". This works.

(b) using JMeter where I get the following error:
WSM-00081: The X.509 certificate is not signed.
Cause: The X509 token used was not signed according to requirements of certificate authentication scenario.
Action: Sign the X509 token (depending upon the reference mechanism used) for certificate authentication.

This is the JMeter signer configuration:
JMeter-Capture-X509

I am using the same JKS keystore for each test, so this is not the issue.

I am attaching the SOAP request message for each case:
(a) Java client request message:
wss10_x509-Request-Eclipse-SUCCESS.txt

(b) JMeter request message:
wss10_x509-Request-johnson-JMeter-FAIL.txt

I have noticed that the following BST Reference element "#BST-BfIWLAzVEEGi7Q9cKEZtpg22 " is included in the working request message Signature element and there is no similar Reference element in the JMeter Signature element for the failed request message:

Working Request Message snippet:
dsig:SignedInfo
<dsig:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
<dsig:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<dsig:Reference URI="#BST-byZclrMEp8xUp2pL19XhCw22">
dsig:Transforms
<dsig:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
dsig:DigestValueKR5r6kv0ERYTCLyK3Gk1KU6OhnM=
</dsig:DigestValue>
</dsig:Reference>
<dsig:Reference URI="#Timestamp-QHxDiLXj12Nh1Bdc2dvTWg22">
dsig:Transforms
<dsig:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
dsig:DigestValue+EMaW6GgiNBRHZ6jam53hGyMAZk=
</dsig:DigestValue>
</dsig:Reference>
<dsig:Reference URI="#Body-opr0oUmWvnjZ1du1XsjdDg22">
dsig:Transforms
<dsig:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
dsig:DigestValueXwKoT4Ub5q8afx8b6znWqzXZ2Fs=
</dsig:DigestValue>
</dsig:Reference>
</dsig:SignedInfo>
dsig:SignatureValueX4WYKrjnQ0DTDZyPF5IbntxHrD2GHLiYl2kLs4b6fC6qltsZE2zgozEFHMRceEZv
vzZHeRye+1D0t8/gnZRLUUF/5akZwVBI4RFZWuakSu1yS725foprZ8rP7CeUrij3
R81hZpqTXzPecqIVhcm7+03CaEYZCY3g+YbQDT57fzenessyl6wOLDqoChtkxIYl
AJHIu2ZNVppB76gMj8bZ0vgFR9hm1baS09ROf0mR9AmcTjYlcwtAClcbM1LLGOQY
6CHyStqJ1uoR5OI76fukxj//xLJOISHKRHd3tU+wZvwU7jczAfYB8bEITXmcbmzg
h3b8L5D8AkgPhJ4nxaGcxA==
</dsig:SignatureValue>
<dsig:KeyInfo xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" Id="KeyInfo-zGFksfYYcrikntWco71d0w22">
<wsse:SecurityTokenReference xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:Reference xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" URI="#BST-byZclrMEp8xUp2pL19XhCw22" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"/>
</wsse:SecurityTokenReference>
</dsig:KeyInfo>
</dsig:Signature>

Failed Request Message snippet:

 <ds:SignedInfo>
      <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
        <ec:InclusiveNamespaces xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList="hel soapenv"/>
      </ds:CanonicalizationMethod>
      <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
      <ds:Reference URI="#TS-20f4f966-d5d3-4e33-946a-bd081730e356">
        <ds:Transforms>
          <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
            <ec:InclusiveNamespaces xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList="hel soapenv wsse"/>
          </ds:Transform>
        </ds:Transforms>
        <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
        <ds:DigestValue>zogmN9dlltiNukTE8AGB4iW+Xaw=</ds:DigestValue>
      </ds:Reference>
      <ds:Reference URI="#id-9df7db44-2071-457b-9d1c-48db860bea46">
        <ds:Transforms>
          <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
            <ec:InclusiveNamespaces xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList="hel"/>
          </ds:Transform>
        </ds:Transforms>
        <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
        <ds:DigestValue>afsdiKkgMV4DLY7E0bceAqlNVI4=</ds:DigestValue>
      </ds:Reference>
    </ds:SignedInfo>
    <ds:SignatureValue>FqytAAUhim6tGhKA+zsxMOdAulrDZZXONemPHrWxzGS3qUZL61TyEtGDpEs4Ls5i/ONJ+Xq9uPA96d1TQq5V628dpBdtTLcq17/hDFzOb08NqNj5Zlclo5zCYCiIqZkROwIQs/P/oLsamuyNen+jjRfMhPtP0BlsvzuCi2Xkowlms+ArcS+Rhzf5bVRYyRU3YAfbAuMh0g8vCfLt4j4s2q76Wjvu0BptbMndKGOfaz9IlxQUTzo6nyOjYIkqWPz+iSwAb9QNr5I9h44tQ31idZybG1ATTKq7u5b5BvlbVqZitrRkc+uBHzzqDAEBaZ3nhHmDmL/5ycDfGPagGrzcUA==</ds:SignatureValue>
    <ds:KeyInfo Id="KI-cd332575-1f32-4ce2-b708-df8ad7bd5950">
      <wsse:SecurityTokenReference wsu:Id="STR-33f423b7-d739-401e-a6b9-aaa7013327e9">
        <wsse:Reference URI="#X509-b73782ac-77ca-46cf-a193-83d9908c5e87" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"/>
      </wsse:SecurityTokenReference>
    </ds:KeyInfo>

Please investigate this at your convenience.
Kieran Murphy

nz.co.breakpoint.jmeter.modifiers.SecurityPart cannot be cast to org.apache.jmeter.testelement.property.JMeterProperty

JMeter 3.2 r17900748 & WS Security for SOAP (jmeter-wssecurity-1.5.jar)
Reproduced in clean JMeter 3.2 r17900748 with jmeter-plugins-manager-0.20.jar and jmeter-wssecurity-1.5.jar

Could not reproduce in 3.3

Steps to reproduce:

  1. Add Thread Group
  2. Add HTTP Request with SOAP Message Signer
  3. Add another HTTP Request with SOAP Message Signer. Add 1 row in Parts to Sign with all three fields filled
  4. Save the script --> Error occurs

Extra note: Error does not occur when both SOAP Message Signer don't have parts to sign, both have parts to sign or #2 and #3 are switched (so first has part to sign and second does not)

Error:
2018-03-29 10:08:47,302 ERROR o.a.j.g.a.ActionRouter: Error processing org.apache.jmeter.gui.action.Save@9573b3b
java.lang.ClassCastException: nz.co.breakpoint.jmeter.modifiers.SecurityPart cannot be cast to org.apache.jmeter.testelement.property.JMeterProperty
at org.apache.jmeter.testelement.property.PropertyIteratorImpl.next(PropertyIteratorImpl.java:41) ~[ApacheJMeter_core.jar:3.2 r1790748]
at org.apache.jmeter.testelement.property.PropertyIteratorImpl.next(PropertyIteratorImpl.java:24) ~[ApacheJMeter_core.jar:3.2 r1790748]
at org.apache.jmeter.save.converters.MultiPropertyConverter.marshal(MultiPropertyConverter.java:57) ~[ApacheJMeter_core.jar:3.2 r1790748]
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:88) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeItem(AbstractCollectionConverter.java:66) ~[xstream-1.4.9.jar:1.4.9]
at org.apache.jmeter.save.converters.TestElementConverter.marshal(TestElementConverter.java:74) ~[ApacheJMeter_core.jar:3.2 r1790748]
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:88) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeItem(AbstractCollectionConverter.java:66) ~[xstream-1.4.9.jar:1.4.9]
at org.apache.jmeter.save.converters.HashTreeConverter.marshal(HashTreeConverter.java:53) ~[ApacheJMeter_core.jar:3.2 r1790748]
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:88) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeItem(AbstractCollectionConverter.java:66) ~[xstream-1.4.9.jar:1.4.9]
at org.apache.jmeter.save.converters.HashTreeConverter.marshal(HashTreeConverter.java:54) ~[ApacheJMeter_core.jar:3.2 r1790748]
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:88) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeItem(AbstractCollectionConverter.java:66) ~[xstream-1.4.9.jar:1.4.9]
at org.apache.jmeter.save.converters.HashTreeConverter.marshal(HashTreeConverter.java:54) ~[ApacheJMeter_core.jar:3.2 r1790748]
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:88) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeItem(AbstractCollectionConverter.java:66) ~[xstream-1.4.9.jar:1.4.9]
at org.apache.jmeter.save.converters.HashTreeConverter.marshal(HashTreeConverter.java:54) ~[ApacheJMeter_core.jar:3.2 r1790748]
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:88) ~[xstream-1.4.9.jar:1.4.9]
at org.apache.jmeter.save.ScriptWrapperConverter.marshal(ScriptWrapperConverter.java:79) ~[ApacheJMeter_core.jar:3.2 r1790748]
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.core.TreeMarshaller.start(TreeMarshaller.java:82) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.marshal(AbstractTreeMarshallingStrategy.java:37) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.XStream.marshal(XStream.java:1067) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.XStream.marshal(XStream.java:1056) ~[xstream-1.4.9.jar:1.4.9]
at com.thoughtworks.xstream.XStream.toXML(XStream.java:1029) ~[xstream-1.4.9.jar:1.4.9]
at org.apache.jmeter.save.SaveService.saveTree(SaveService.java:303) ~[ApacheJMeter_core.jar:3.2 r1790748]
at org.apache.jmeter.gui.action.Save.doAction(Save.java:223) ~[ApacheJMeter_core.jar:3.2 r1790748]
at org.apache.jmeter.gui.action.ActionRouter.performAction(ActionRouter.java:74) ~[ApacheJMeter_core.jar:3.2 r1790748]
at org.apache.jmeter.gui.action.ActionRouter.lambda$actionPerformed$0(ActionRouter.java:59) ~[ApacheJMeter_core.jar:3.2 r1790748]
at java.awt.event.InvocationEvent.dispatch(Unknown Source) [?:1.8.0_144]
at java.awt.EventQueue.dispatchEventImpl(Unknown Source) [?:1.8.0_144]
at java.awt.EventQueue.access$500(Unknown Source) [?:1.8.0_144]
at java.awt.EventQueue$3.run(Unknown Source) [?:1.8.0_144]
at java.awt.EventQueue$3.run(Unknown Source) [?:1.8.0_144]
at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_144]
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) [?:1.8.0_144]
at java.awt.EventQueue.dispatchEvent(Unknown Source) [?:1.8.0_144]
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) [?:1.8.0_144]
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) [?:1.8.0_144]
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) [?:1.8.0_144]
at java.awt.EventDispatchThread.pumpEvents(Unknown Source) [?:1.8.0_144]
at java.awt.EventDispatchThread.pumpEvents(Unknown Source) [?:1.8.0_144]
at java.awt.EventDispatchThread.run(Unknown Source) [?:1.8.0_144]

Missing support for "http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p" Key Encryption Algorithm

The SOAP Message Encrypter does not support "http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p" as the Key Encryption Algorithm. I am trying to test some predefined security polices in Oracle Web Services Manager which demands the client to use specific algorithms. I am getting the following error: [2019-09-19T10:00:29.601-07:00] [osb_server1] [ERROR] [WSM-00030] [oracle.wsm.resources.security] [tid: [ACTIVE].ExecuteThread: '16' for queue: 'weblogic.kernel.Default (self-tuning)'] [userId: ] [ecid: 60ad4447-d060-4a79-b828-2e2b3eb416ba-00000221,0] [APP: Service Bus Kernel] [partition-name: DOMAIN] [tenant-name: GLOBAL] [FlowId: 0000MpATx8UFw000jzwkno1TWYcM00001B] [oracle.wsm.policy.name: oracle/wss10_message_protection_service_policy] The encryption method key wrap algorithms do not match : Expected : http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p, Actual : http://www.w3.org/2009/xmlenc11#rsa-oaep.

try to sign with jks file (with private key inside

SecretKey key = (SecretKey)((Merlin) getInstance()).getKeyStore()

2019-10-02 09:31:05,390 DEBUG o.a.w.c.u.Loader: Trying to find [C:/WIN-B3GPCUINS7V.jks] using org.apache.jmeter.DynamicClassLoader@5ef04b5 class loader.
2019-10-02 09:31:05,390 DEBUG o.a.w.c.u.Loader: Trying to find [C:/WIN-B3GPCUINS7V.jks] using org.apache.jmeter.DynamicClassLoader@5ef04b5 class loader.
2019-10-02 09:31:05,390 DEBUG o.a.w.c.u.Loader: Trying to find [C:/WIN-B3GPCUINS7V.jks] using ClassLoader.getSystemResource().
2019-10-02 09:31:05,391 DEBUG o.a.w.c.c.Merlin: The KeyStore C:/WIN-B3GPCUINS7V.jks of type JCEKS has been loaded
2019-10-02 09:31:05,392 ERROR n.c.b.j.m.AbstractWSSecurityPreProcessor: Processing failed! 
java.lang.ClassCastException: sun.security.rsa.RSAPrivateCrtKeyImpl cannot be cast to javax.crypto.SecretKey
	at nz.co.breakpoint.jmeter.modifiers.CryptoTestElement.getSecretKey(CryptoTestElement.java:43) ~[jmeter-wssecurity-1.7.jar:?]
	at nz.co.breakpoint.jmeter.modifiers.WSSSignaturePreProcessor.build(WSSSignaturePreProcessor.java:93) ~[jmeter-wssecurity-1.7.jar:?]
	at nz.co.breakpoint.jmeter.modifiers.AbstractWSSecurityPreProcessor.process(AbstractWSSecurityPreProcessor.java:63) [jmeter-wssecurity-1.7.jar:?]
	at org.apache.jmeter.threads.JMeterThread.runPreProcessors(JMeterThread.java:935) [ApacheJMeter_core.jar:5.1.1 r1855137]
	at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:537) [ApacheJMeter_core.jar:5.1.1 r1855137]
	at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:486) [ApacheJMeter_core.jar:5.1.1 r1855137]
	at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:253) [ApacheJMeter_core.jar:5.1.1 r1855137]
	at java.lang.Thread.run(Unknown Source) [?:1.8.0_201]```

Decrypter with multiple keys

The SOAP Message Decrypter has a single "Private Key Password" field for unlocking the decryption key in the keystore. This works fine if the same encryption key is used for all encrypted elements.

However, if there are different keys used, the keystore entries for all decryption keys needs to share the same password for this to work.

It would be better to be able to specify individual passwords for different keystore entries.

Add Support for Key Encryption Algorithm = http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p

Hi,
I am testing a web service running in Oracle Service Bus / Oracle Weblogic Server. The Web Service uses Oracle Web Services Manager security policy: oracle.wsm.policy.name: oracle/wss10_message_protection_service_policy.
When I configure the Soap Message Encrypter, there is no option for setting the parameter Key Encryption Algorithm = http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p.

image

I get the following error from Oracle Web Services Manager when I try to use a different algorithm e.g. http://www.w3.org/2009/xmlenc11#rsa-oaep:

2019-09-19T10:00:29.601-07:00] [osb_server1] [ERROR] [WSM-00030] [oracle.wsm.resources.security] [tid: [ACTIVE].ExecuteThread: '16' for queue:
'weblogic.kernel.Default (self-tuning)'] [userId: ] [ecid: 60ad4447-d060-4a79-b828-2e2b3eb416ba-00000221,0] [APP: Service Bus Kernel]
[partition-name: DOMAIN] [tenant-name: GLOBAL] [FlowId: 0000MpATx8UFw000jzwkno1TWYcM00001B] [oracle.wsm.policy.name: oracle/wss10_message_protection_service_policy]
The encryption method key wrap algorithms do not match : Expected : http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p, Actual : http://www.w3.org/2009/xmlenc11#rsa-oaep.

It would be great if you could restore the support for Key Encryption Algorithm = http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p. I see it was recently removed.

Thanks, Kieran Murphy
Email: [email protected]

SOAP Message Signer as a post processor

Hi,
I am testing a SOAP request with WS-Security enabled. While the request is sent, We are signing and encrypting the request and while receiving response we are Decrypting the response and validating the signature.

I am using WS-security plugin and have added SOAP Message Signer(PreProcessor), SOAP Message Encrypter (PreProcessor) and SOAP Message Decrypter (PostProcessor) in the request. However not sure how to validate the signature for the response.

Can someone please help in creating a plugin or enhancement for SOAP Message Signer as a PostProcessor ?

BinarySecurityToken is not getting signed

A Binary Security Token, representing the signing cert in the WSS header, is not getting signed when included in the "Parts To Sign" list.
(This is due to the token not yet present in the DOM when the signature is calculated by wss4j.)

In SoapUI this is working as expected.

Scripts fail with NPE after version upgrade due to missing attachments element

When running scripts that were created with a plugin version before 1.6 the below NPE is thrown, presumably due to the missing <collectionProp name="attachments"/> and the element not being initialized when the script is unmarshalled by XStream
protected List<Attachment> attachments = new ArrayList<Attachment>();

2019-09-18 14:23:18,835 ERROR n.c.b.j.m.AbstractWSSecurityPreProcessor: Processing failed! 
java.lang.NullPointerException: null
	at nz.co.breakpoint.jmeter.modifiers.AbstractWSSecurityTestElement.updateAttachmentCallbackHandler(AbstractWSSecurityTestElement.java:48) ~[jmeter-wssecurity-1.7.jar:?]
	at nz.co.breakpoint.jmeter.modifiers.WSSSignaturePreProcessor.build(WSSSignaturePreProcessor.java:98) ~[jmeter-wssecurity-1.7.jar:?]
	at nz.co.breakpoint.jmeter.modifiers.AbstractWSSecurityPreProcessor.process(AbstractWSSecurityPreProcessor.java:63) [jmeter-wssecurity-1.7.jar:?]
	at org.apache.jmeter.threads.JMeterThread.runPreProcessors(JMeterThread.java:935) [ApacheJMeter_core.jar:5.1.1 r1855137]
	at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:537) [ApacheJMeter_core.jar:5.1.1 r1855137]
	at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:486) [ApacheJMeter_core.jar:5.1.1 r1855137]
	at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:253) [ApacheJMeter_core.jar:5.1.1 r1855137]
	at java.lang.Thread.run(Thread.java:745) [?:1.8.0_121]

Support for UsernameToken - Password Type - No Password

Hi, I have been trying to use jmeter ws-security plugin to digitally sign Body, UsernameToken, and Timestamp of our security headers and our WSS4J SOAP endpoints have UsernameToken securement validation for 'No Password'. This means that the password xml fields cannot be present in the UsernameToken portion of the xml.

For example: -

<wsse:UsernameToken>
                <wsse:Username>${username}</wsse:Username>
</wsse:UsernameToken>

I have verified that this is supported by Spring 4.x and its WSS4J implementation using the following application context configuration.

<bean id="wsSecurityUserNameToken" class="org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor">
        <property name="securementActions" value="UsernameToken"/>
        <property name="securementUsername" value="username"/>
        <property name="securementPassword" value=""/>
        <property name="securementPasswordType" value="PasswordNone"/>
        <property name="securementTimeToLive" value="300"/>
        <property name="futureTimeToLive" value="60"/>
</bean>

In LoadRunner configuration we can achieve it using PasswordOptions as SendNone -

web_service_set_security(
SECURITY_TOKEN, "Type=PFX","LogicalName=PFXFileToken1", "FilePath=mykeystore.p12", "FilePassword=C0mpa5","Add=False",
SECURITY_TOKEN, "Type=USERNAME","LogicalName=UsernameToken1", "UserName=username", "Password=Password", "PasswordOptions=SendNone","IsNonceIncluded=False","Add=True",  MESSAGE_SIGNATURE, "UseToken=PFXFileToken1","SignatureOptions=IncludeBody|IncludeTimestamp","TransformAlgorithm=http://www.w3.org/2001/10/xml-exc-c14n#","CanonicalizationAlgorithm=http://www.w3.org/2001/10/xml-exc-c14n#",
        TIME_STAMP, "Exclude=False",
        LAST);

Lastly, I notice that WSS4J's WSCONSTANTS contains UT_NOPASSWORD which I believe is the same setting.

Is there any way to achieve the same using the jmeter ws security plugin?

I have made various attempts using the Username preprocessor with no success. I have also tried to add username fields to the raw body of the message but without the password fields present, it will not sign it.

Any help or advice is much appreciated as we would like to use jmeter with ws-security to load test our endpoints.

Thanks for your help!

DerivedKeyToken Implementation

I have a use-case that requires usage of a DerivedKeyToken. From what I can tell this is not currently supported by this plugin. I'd be happy to work on the implementation, but would require some direction. In the past, I've mostly relied on WSDLs to auto-configure the necessary security elements which isn't an option here.

Any guidance that anyone could provide on how to implement this? Thanks!

Jmeter decrypt WS-Security response

Thanks for sharing this plugin. This plugin works well with the encryption and signer. Wondering, if we we have similar plugin for the decryption as well. So far I could able to see the successful response from the server through Jmeter, but couldnt verify the response as it is in encrypted format. Your comments are much appreciated.
Thanks
1
2

UsernameToken & Timestamp

Hi,

In my SoapUI project, I have a "Username" and "Timestamp" configurations as part of my WS-Security Configurations. I was wondering if there was any way of reproducing these two configs with your plugin.

Do I need to add a certain native sampler, config, pre-processor, etc ? Or do I simply need to add the XML directly into my raw body request?

I do have Timestamp and UsernameToken with their correct namespaces in my "Parts to Sign"

Thanks a lot

Suggestion/Question (not an issue)

This question is related to the first issue I encountered; the UsernameToken and Timestamp

Hi,

I was just wondering if you would consider adding a few fields into the plugin. The fields in question would be "username", "password" and "timestamp". The username and password field would generate and sign

<wsse:UsernameToken>
    <wsse:Username>username</wsse:Username>
    <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">password encoded with Base64(SHA-1)</wsse:Password>
    <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">encoded random nonce</wsse:Nonce>
</wsse:UsernameToken>

The timestamp would generate and sign

<wsu:Timestamp>
     <wsu:Created>current timestamp ("yyyy-MM-dd'T'HH:mm:ss.SS'Z'")</wsu:Created>
     <wsu:Expires>current timestamp + amount of milliseconds/minutes set in the field ("yyyy-MM-dd'T'HH:mm:ss.SS'Z'")</wsu:Expires>
</wsu:Timestamp>

This would restrain me from having to use a custom pre-processor that's executed before the "SOAP Message Signer", but I'm sure it could benefit the rest of the world as well :) !

Here's an example of the pre-processor I currently use to fill my SOAP request:

import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.jmeter.protocol.http.sampler.SoapSampler;
import java.security.*;
import java.text.SimpleDateFormat;
import java.util.UUID;

try {		
	//Generate nonce
	SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
	byte[] nonceBytes = new byte[16]; 
	random.setSeed(System.currentTimeMillis()); 
	random.nextBytes(nonceBytes); 
	String nonce = new String(Base64.encodeBase64(nonceBytes), "UTF-8");
	
	//Generate created & encoded password (password digest)
	String username = "SoapUIClient";
	String password = "changeit";
	String action = "action_url" 
	String stringToEncode = nonce + created + password;
	String password_digest = Base64.encodeBase64String(DigestUtils.sha1(stringToEncode));
	String created, expires;
	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SS'Z'");
	Date date = new Date();
	
	date.setHours(date.getHours() + 4);
	created = sdf.format(date);
	date.setMinutes(date.getMinutes() + 5);
	expires = sdf.format(date);
	
	//Get and modify the body request
	String bodyRequest = sampler.getArguments().getArgument(0).getValue();
	String[] splitResult = bodyRequest.split("<soapenv:Header>");
	String XMLtoAdd = "<soapenv:Header xmlns:wsa=\"http://www.w3.org/2005/08/addressing\">" +     
			"	<wsse:Security xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\" xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">" +
			"		<wsse:UsernameToken>" +
			"			<wsse:Username>"+ username +"</wsse:Username>" + 
                        "			<wsse:Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest\">"+password_digest+"</wsse:Password>" + 
			"			<wsse:Nonce EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\">"+nonce+"</wsse:Nonce>" +
			"		</wsse:UsernameToken>" +
			"		<wsu:Timestamp>" +
			"			<wsu:Created>"+created+"</wsu:Created>" +
			"			<wsu:Expires>"+expires+"</wsu:Expires>" + 
			"		</wsu:Timestamp>" +
			"	</wsse:Security>";
						
	bodyRequest = splitResult[0] + XMLtoAdd + splitResult[1];
	splitResult = bodyRequest.split("</ser:serviceContext>");
	XMLtoAdd =	"</ser:serviceContext>"+
				"<wsa:Action>"+ action +"</wsa:Action>"+
				"<wsa:MessageID>uuid:"+ UUID.randomUUID().toString() +"</wsa:MessageID>";

	//Set the modified body to the HTTP request
	bodyRequest = splitResult[0] + XMLtoAdd + splitResult[1];
	sampler.getArguments().getArgument(0).setValue(bodyRequest);

} catch (Exception e) {
	e.printStackTrace();
	log.warn(e.getMessage());
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.