Support for 2-way-SSL (Client Certificate) in webMethods.io B2B
Tags: b2b, ssl, client, tutorial
Published: 2021-10-27 11:45:27

---
title: Support for 2-way-SSL (Client Certificate) in webMethods.io B2B
published: true
date: 2021-09-02 07:53:44 UTC
tags: #b2b, #ssl, #client, #tutorial
canonical_url: https://tech.forums.softwareag.com/t/support-for-2-way-ssl-client-certificate-in-webmethods-io-b2b/244026
---

2-way SSL certificate (client certificate) can be defined as a digital certificate used to authenticate the identity of the partner user. A 2-way SSL certificate ensures the B2B server that it is communicating with a legitimate partner user.

Contrary to SSL certificates, 2-way SSL certificates are used to validate the identity of the partner user. Simply put, it works as a password, but without any intervention/input from the user. This way, the B2B server makes sure that it’s connecting to the permitted user and that party is safe to communicate with.

Now you might be wondering ‘Don’t passwords do the same thing?’ Well, sometimes passwords are not good enough. We often fall prey to password cracking techniques such as brute-force attacks and keyloggers. That’s why passwords are no longer sufficient when you have some really highly sensitive B2B document.

So, there might be some documents or files that you want only designated people to access. But as passwords are not secure enough, you’ll have to explore your options. That’s where 2-way SSL certificates come in. Instead of validating people via only passwords, 2-way SSL certificates authenticate people by the systems they use. If the user doesn’t have the granted permissions, he/she won’t be granted access resources. To make it even more secure, B2B enforce you to combine the use of 2-way SSL certificates with passwords. In technical terms, this is called ‘Two-factor Authentication.’ It is an absolute must for organizations dealing with sensitive data –both internal as well as external. And you know what happens when you don’t employ two-factor authentication?

Now that we know about 2-way-SSL , let us explore how we can configure and setup 2-way-SSL in [webMethods.io](http://webMethods.io) B2B. Let’s assume two tenants namely swag and acme, behaving like a sender-receiver pair.

### Create these assets on tenant SwAG to configure inbound 2-way-SSL capability:

> **_NOTE:_** Inbound 2-way-SSL is only supported for channel type AS2-IN, HTTP-IN and RNIF-IN.

#### Design-time assets created on tenant SwAG:

- Enterprise → SwAG(Sender) with ID types DUNS(123456789) and EDIINT AS2(SwAGAS2)
- Partner → Acme(Receiver) with ID types DUNS(987654321) and EDIINT AS2(AcmeAS2)
- Channel → Acme\_http\_in

1. Create the partners between which the documents have to be exchanged 
In this case, SwAG (Enterprise) and Acme (Partner) are created with Identity Types DUNS and EDIINT AS2. 
2. Create partner user and associate it with the partners  
In this example a partner user with name ‘acme\_user’ is created and associated with the partner.  
 ![in_create_partner_user](https://aws1.discourse-cdn.com/techcommunity/original/3X/5/0/5029030b0f05fb5e22a722892069852a2fee0f45.gif)
3. Create an inbound channel of type HTTP-IN for receiving the Document from partner Acme and associate with it
 ![in_create_http_in_channel](https://aws1.discourse-cdn.com/techcommunity/original/3X/7/a/7a6aaf993de02d3f0741dfcf93bf5e252ed04334.gif)
4. Generate or upload 2-way-SSL certificate for the partner Acme 
 ![in_generate_2_way_SSL_cert](https://aws1.discourse-cdn.com/techcommunity/original/3X/0/d/0d68294f3a5a6b6d15561b9f7650bedd27d6f79c.gif)
5. Prepare a test client like ([Postman](https://www.postman.com/), [Insomnia](https://insomnia.rest/)) to post the data to endpoint. Here in this example, i will use Insomnia. Now test the configuration without 2-way-ssl to ensure everything is working as expected.  
Since everything is working without 2-way-SSL, let us try with 2-way-SSL.
> **_NOTE:_** For 2-way-SSL to work, you will need to add port **8443** in the endpoint generated (as part of result of the inbound channel configuration).

  - Without 2-way-SSL certificates configured  
 ![in_post_without_2_way_ssl_cert](https://aws1.discourse-cdn.com/techcommunity/original/3X/7/8/7873b45368a95243069ab0c4e87570fc3d0aa9ed.gif)

  - With 2-way-SSL certificates configured  

### Create these assets on tenant Acme to configure outbound 2-way-SSL capability:

> **_NOTE:_** Outbound 2-way-SSL is only achievable through channel type AS2-OUT and HTTP-OUT.

#### Design-time assets created on tenant Acme:

- Enterprise → Acme(Sender) with ID types DUNS(987654321) and EDIINT AS2(AcmeAS2)
- Partner → SwAG(Receiver) with ID types DUNS(123456789) and EDIINT AS2(SwAGAS2)
- Channel → SwAG\_http\_in, SwAG\_http\_out

1. Create the partners between which the document needs to be exchanged  
In this case, Acme (Enterprise) and SwAG (Partner) are created with Identity Types DUNS and EDIINT AS2.  
2. Create Partner users and associate it with the partners 
Partner user with name ‘swag\_user’ is created and associated with the partners.  
 ![out_create_partner_user](https://aws1.discourse-cdn.com/techcommunity/original/3X/e/d/edbc0b2e9b2e6089e152d5fb6d91ef822263a500.gif)
3. Create HTTP-OUT outbound channel for sending the Document from partner SwAG and associate with the enterprise. Here we will use the HTTP-IN channel endpoint and partner user of partner Acme from tenant SwAG.
> **_NOTE:_** Ensure SSL in config(only for HTTP-OUT) is enabled so that B2B can set SSL certificate configured while posting data to outbound endpoint.
4. Submit a payload to emulate the document exchange between the sender-receiver pair  
Post an EDI 850 payload over the HTTP Inbound channel Endpoint URL, with following request information.
```
curl --request POST \
--url https://{subdomain}.int-aws-us.webmethods.io/b2b/routes/channel/{channelId}\
--header 'Authorization: Basic {base64 encodedString}' \
--header 'Content-Type: application/edi' \
--data 'ISA*00* *00* *01*222222222 *01*777777777 *020226*1534*U*00401*000000009*0*T*>~
GS*PO*SENDERGS*007326879*20020226*1534*1*X*004010~
ST*850*000000009~
BEG*00*SA*A99999-01**19970214~
REF*VR*54321~
ITD*01*3*1 **15** 16~
DTM*002*19971219~
DTM*002*19971219~
N1*BT*BUYSNACKS INC.*9*1223334444~
N3*P.O. BOX 0000~
N4*TEMPLE*TX*76503~
N1*ST*BUYSNACKS PORT*9*1223334445~
N3*1000 N. SAMPLE HIGHWAY~
N4*ATHENS*GA*30603~
PO1 **16*CA*12.34** CB*000111111*UA*002840022222~
PID*F **** CRUNCHY CHIPS LSS~
PO4*48*7.89*LB~
PO1 **13*CA*12.34** CB*000555555*UA*002840033333~
PID*F **** NACHO CHIPS LSS~
PO4*48*8.9*LB~
PO1 **32*CA*12.34** CB*000666666*UA*002840044444~
PID*F **** POTATO CHIPS~
PO4*72*6.78*LB~
PO1 **51*CA*12.34** CB*000874917*UA*002840055555~
PID*F **** CORN CHIPS~
PO4*48*8.9*LB~
PO1 **9*CA*12.34** CB*000874958*UA*002840066666~
PID*F **** BBQ CHIPS~
PO4*48*4.5*LB~
PO1 **85*CA*12.34** CB*000874990*UA*002840077777~
PID*F **** GREAT BIG CHIPS LSS~
PO4*48*4.56*LB~
PO1 **1*CA*12.34** CB*000875088*UA*002840088888~
PID*F **** MINI CHIPS LSS~
PO4*48*4.56*LB~
CTT*7~
SE*35*000000009~
GE*1*1~
IEA*1*000000009~
'
```
5. Configure the SSL certificate in Enterprise Acme with the 2-way-SSL certificates generated in SwAG tenant preparation (in step 4).  
To convert the download certificate in desired format, run following steps on terminal.
> **_NOTE:_** The default password for download cert is `changeit`.
```
openssl pkcs12 -in {partnerName}.pfx -nocerts -nodes -out key.pem
openssl rsa -in key.pem -out server.key
openssl pkcs12 -in {partnerName}.pfx -out mycerts.cer -nokeys -clcerts 
```
Also, change the outbound channel port which we created from 443 to 8443.  
6. Now post the data, (follow the same steps mentioned in step 4 of this section).  

## Troubleshooting

- 400 Bad Request

If certificate is not passed as part of requests, you will get the error 400 Bad request as shown in image below. This error can also appear if you are sending certificate’s not known to software AG infrastructures.

![400_bad_request](https://aws1.discourse-cdn.com/techcommunity/optimized/3X/c/1/c191cbd3b174f953504c3657d7a3f2a792233421_2_690x130.png)
- 403 Forbidden

If you are passing incorrect certificate, like which are not known to server you will get this error.

![403_Forbidden](https://aws1.discourse-cdn.com/techcommunity/optimized/3X/0/e/0eb0af1370fbd751b62610442b0cc4da296a99af_2_690x148.png)
- 401 Invalid credentials

For 2-way-SSL to work, you must provide 2-way-SSL certificate configured/generated along with the valid user credentials correctly.

![401_invalid_credentials](https://aws1.discourse-cdn.com/techcommunity/optimized/3X/4/9/49ccb54bce9c17d9df74810ec560e5230e856dbf_2_690x140.png)
- 401 Invalid or expired session identifier

Your session expired. Send the document again to create the session.

![401_invalid_session](https://aws1.discourse-cdn.com/techcommunity/optimized/3X/6/d/6d985e39db8d6bdaba2ec33f1a1d2c92c5ebf45e_2_690x262.png)

## References

1. [Client Certificate](https://cheapSSLsecurity.com/blog/client-certificate-vs-server-certificate-simplifying-the-difference/) 
2. [Adding a Partner Profile](https://docs.webmethods.io/b2b/webmethods_io_b2b_online_help/chapter3/index.html#ta-add_partner)
3. [Adding a Partner User](https://docs.webmethods.io/b2b/webmethods_io_b2b_online_help/chapter4/#ta-add_users)
4. [Associating or Mapping a User with a Partner](https://docs.webmethods.io/b2b/webmethods_io_b2b_online_help/chapter3/#ta-associating_users_partners)
5. [Creating a Channel](https://docs.webmethods.io/b2b/webmethods_io_b2b_online_help/chapter2/#ta-add_channels)
6. [Associating or Mapping an Inbound Channel with a Partner](https://docs.webmethods.io/b2b/webmethods_io_b2b_online_help/chapter3/#ta-associating_partners_with_inbound_channels)
7. [Associating or Mapping an Outbound Channel with a Partner](https://docs.webmethods.io/b2b/webmethods_io_b2b_online_help/chapter3/#ta-associating_partners_with_in_channels)
8. [Adding a Certificate Set for a Partner](https://docs.webmethods.io/b2b/webmethods_io_b2b_online_help/chapter3/index.html#ta-add_certificate)
9. [Adding a 2-Way SSL/TLS Certificate for a Partner](https://docs.webmethods.io/b2b/webmethods_io_b2b_online_help/chapter3/index.html#ta-2way_SSL_certificate_usecase)

[Read full topic](https://tech.forums.softwareag.com/t/support-for-2-way-ssl-client-certificate-in-webmethods-io-b2b/244026)