Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorporate secure-socket configuration for ballerina IBM MQ connector #23

Merged
merged 27 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ed66d87
[Automated] Update the native jar versions
ayeshLK Nov 6, 2023
c30f6fa
Add secuire-socket configurations to the ballerina API
ayeshLK Nov 6, 2023
b5bfc8c
Refactor SSL configurations
ayeshLK Nov 6, 2023
d0f6696
Add secure-socket configuration support for native code
ayeshLK Nov 7, 2023
db9b47a
Update doc comments
ayeshLK Nov 7, 2023
600204b
Update docker-compose configurations
ayeshLK Nov 8, 2023
56bfdf6
Resolve merge conflicts
ayeshLK Nov 8, 2023
ab52ff4
Update docker compose configurations
ayeshLK Nov 9, 2023
76cb50b
Fix secure-socket type issue
ayeshLK Nov 9, 2023
4a7037a
Update server-client certs
ayeshLK Nov 10, 2023
07870f8
[Automated] Update the native jar versions
ayeshLK Nov 10, 2023
f7d3c4a
Add test cases for IBM MQ secure socket configurations
ayeshLK Nov 10, 2023
ad0c30c
[Automated] Update the native jar versions
ayeshLK Nov 10, 2023
0ceb868
Add missing dependencies
ayeshLK Nov 10, 2023
cc090a8
Resolve merge conflicts
ayeshLK Nov 10, 2023
5232bf8
Move all the constant values into one file
ayeshLK Nov 10, 2023
90a771a
Suppress unnecessary warnings
ayeshLK Nov 10, 2023
012aba2
Fix review comments
ayeshLK Nov 13, 2023
c18c7aa
Resolve merge conflicts
ayeshLK Nov 13, 2023
12c8773
Merge pull request #1 from ayeshLK/conflict_resolution
ayeshLK Nov 13, 2023
d92f87b
Merge remote-tracking branch 'upstream/main'
ayeshLK Nov 13, 2023
feb95ed
Update change log
ayeshLK Nov 13, 2023
8c701db
Refactor type name
ayeshLK Nov 13, 2023
47d4209
Update SSL related resources
ayeshLK Nov 14, 2023
1883582
Add truststore/keystore based test cases
ayeshLK Nov 14, 2023
0f79f8b
Update SSL test resources
ayeshLK Nov 14, 2023
0751253
Update test cases
ayeshLK Nov 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
dependencies-toml-version = "2"
distribution-version = "2201.8.0"

[[package]]
org = "ballerina"
name = "crypto"
version = "2.5.0"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "time"}
]
modules = [
{org = "ballerina", packageName = "crypto", moduleName = "crypto"}
]

[[package]]
org = "ballerina"
name = "jballerina.java"
Expand Down Expand Up @@ -41,7 +53,6 @@ modules = [
org = "ballerina"
name = "time"
version = "2.4.0"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
]
Expand All @@ -54,6 +65,7 @@ org = "ballerinax"
name = "ibm.ibmmq"
version = "0.1.1"
dependencies = [
{org = "ballerina", name = "crypto"},
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "test"},
{org = "ballerina", name = "time"}
Expand Down
4 changes: 2 additions & 2 deletions ballerina/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ task commitTomlFiles {
standardOutput = stdOut
}
println stdOut.toString()
sleep(5 * 1000)
sleep(10 * 1000)
} else {
println "IBMMQ server is already running."
}
Expand All @@ -152,7 +152,7 @@ task commitTomlFiles {
standardOutput = stdOut
}
println stdOut.toString()
sleep(5 * 1000)
sleep(10 * 1000)
} else {
println "IBMMQ server is not started."
}
Expand Down
105 changes: 105 additions & 0 deletions ballerina/constants.bal
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,108 @@ public const int MQGMO_CONVERT = 16384;

# Subscribe Option create
public const int MQSO_CREATE = 2;

// SSL cipher suite related constants

# SSL cipher suite using ECDHE-ECDSA for key exchange with 3DES encryption and SHA integrity.
public const string SSL_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA = "SSL_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA";

# SSL cipher suite using ECDHE-ECDSA for key exchange with AES 128-bit encryption and SHA-256 integrity.
public const string SSL_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 = "SSL_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256";

# SSL cipher suite using ECDHE-ECDSA for key exchange with AES 128-bit GCM encryption and SHA-256 integrity.
public const string SSL_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 = "SSL_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256";

# SSL cipher suite using ECDHE-ECDSA for key exchange with AES 256-bit CBC encryption and SHA-384 integrity.
public const string SSL_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 = "SSL_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384";

# SSL cipher suite using ECDHE-ECDSA for key exchange with AES 256-bit GCM encryption and SHA-384 integrity.
public const string SSL_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 = "SSL_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384";

# SSL cipher suite using ECDHE-ECDSA for key exchange with NULL encryption and SHA integrity (not recommended for production use).
public const string SSL_ECDHE_ECDSA_WITH_NULL_SHA = "SSL_ECDHE_ECDSA_WITH_NULL_SHA";

# SSL cipher suite using ECDHE-ECDSA for key exchange with RC4 128-bit encryption and SHA integrity (not recommended for production use).
public const string SSL_ECDHE_ECDSA_WITH_RC4_128_SHA = "SSL_ECDHE_ECDSA_WITH_RC4_128_SHA";

# SSL cipher suite using ECDHE-RSA for key exchange with 3DES encryption and SHA integrity.
public const string SSL_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA = "SSL_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA";

# SSL cipher suite using ECDHE-RSA for key exchange with AES 128-bit encryption and SHA-256 integrity.
public const string SSL_ECDHE_RSA_WITH_AES_128_CBC_SHA256 = "SSL_ECDHE_RSA_WITH_AES_128_CBC_SHA256";

# SSL cipher suite using ECDHE-RSA for key exchange with AES 128-bit GCM encryption and SHA-256 integrity.
public const string SSL_ECDHE_RSA_WITH_AES_128_GCM_SHA256 = "SSL_ECDHE_RSA_WITH_AES_128_GCM_SHA256";

# SSL cipher suite using ECDHE-RSA for key exchange with AES 256-bit CBC encryption and SHA-384 integrity.
public const string SSL_ECDHE_RSA_WITH_AES_256_CBC_SHA384 = "SSL_ECDHE_RSA_WITH_AES_256_CBC_SHA384";

# SSL cipher suite using ECDHE-RSA for key exchange with AES 256-bit GCM encryption and SHA-384 integrity.
public const string SSL_ECDHE_RSA_WITH_AES_256_GCM_SHA384 = "SSL_ECDHE_RSA_WITH_AES_256_GCM_SHA384";

# SSL cipher suite using ECDHE-RSA for key exchange with NULL encryption and SHA integrity (not recommended for production use).
public const string SSL_ECDHE_RSA_WITH_NULL_SHA = "SSL_ECDHE_RSA_WITH_NULL_SHA";

# SSL cipher suite using ECDHE-RSA for key exchange with RC4 128-bit encryption and SHA integrity (not recommended for production use).
public const string SSL_ECDHE_RSA_WITH_RC4_128_SHA = "SSL_ECDHE_RSA_WITH_RC4_128_SHA";

# SSL cipher suite using RSA for key exchange with 3DES encryption and SHA integrity.
public const string SSL_RSA_WITH_3DES_EDE_CBC_SHA = "SSL_RSA_WITH_3DES_EDE_CBC_SHA";

# SSL cipher suite using RSA for key exchange with AES 128-bit encryption and SHA integrity.
public const string SSL_RSA_WITH_AES_128_CBC_SHA = "SSL_RSA_WITH_AES_128_CBC_SHA";

# SSL cipher suite using RSA for key exchange with AES 128-bit encryption, SHA-256 integrity.
public const string SSL_RSA_WITH_AES_128_CBC_SHA256 = "SSL_RSA_WITH_AES_128_CBC_SHA256";

# SSL cipher suite using RSA for key exchange with AES 128-bit GCM encryption, SHA-256 integrity.
public const string SSL_RSA_WITH_AES_128_GCM_SHA256 = "SSL_RSA_WITH_AES_128_GCM_SHA256";

# SSL cipher suite using RSA for key exchange with AES 256-bit CBC encryption and SHA integrity.
public const string SSL_RSA_WITH_AES_256_CBC_SHA = "SSL_RSA_WITH_AES_256_CBC_SHA";

# SSL cipher suite using RSA for key exchange with AES 256-bit CBC encryption, SHA-256 integrity.
public const string SSL_RSA_WITH_AES_256_CBC_SHA256 = "SSL_RSA_WITH_AES_256_CBC_SHA256";

# SSL cipher suite using RSA for key exchange with AES 256-bit GCM encryption, SHA-384 integrity.
public const string SSL_RSA_WITH_AES_256_GCM_SHA384 = "SSL_RSA_WITH_AES_256_GCM_SHA384";

# SSL cipher suite using RSA for key exchange with DES encryption and SHA integrity (not recommended for production use).
public const string SSL_RSA_WITH_DES_CBC_SHA = "SSL_RSA_WITH_DES_CBC_SHA";

# SSL cipher suite using RSA for key exchange with NULL encryption and SHA-256 integrity (not recommended for production use).
public const string SSL_RSA_WITH_NULL_SHA256 = "SSL_RSA_WITH_NULL_SHA256";

# SSL cipher suite using RSA for key exchange with RC4 128-bit encryption and SHA integrity (not recommended for production use).
public const string SSL_RSA_WITH_RC4_128_SHA = "SSL_RSA_WITH_RC4_128_SHA";

# TLS 1.2 protocol version.
public const string TLS12 = "*TLS12";

# SSL cipher suite using AES 128-bit GCM encryption, SHA-256 integrity.
public const string TLS_AES_128_GCM_SHA256 = "TLS_AES_128_GCM_SHA256";

# SSL cipher suite using AES 256-bit GCM encryption, SHA-384 integrity.
public const string TLS_AES_256_GCM_SHA384 = "TLS_AES_256_GCM_SHA384";

# SSL cipher suite using ChaCha20-Poly1305 encryption, SHA-256 integrity.
public const string TLS_CHACHA20_POLY1305_SHA256 = "TLS_CHACHA20_POLY1305_SHA256";

# SSL cipher suite using AES 128-bit CCM encryption, SHA-256 integrity.
public const string TLS_AES_128_CCM_SHA256 = "TLS_AES_128_CCM_SHA256";

# SSL cipher suite using AES 128-bit CCM 8 encryption, SHA-256 integrity.
public const string TLS_AES_128_CCM_8_SHA256 = "TLS_AES_128_CCM_8_SHA256";

# Any supported SSL/TLS cipher suite.
public const string ANY = "*ANY";

# TLS 1.3 protocol version.
public const string TLS13 = "*TLS13";

# TLS 1.2 or higher protocol version.
public const string TLS12ORHIGHER = "*TLS12ORHIGHER";

# TLS 1.3 or higher protocol version.
public const string TLS13ORHIGHER = "*TLS13ORHIGHER";

27 changes: 26 additions & 1 deletion ballerina/tests/resources/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,34 @@ services:
mq:
image: icr.io/ibm-messaging/mq:latest
container_name: ibmmq-test
depends_on:
mq-tls:
condition: service_started
ports:
- "1414:1414"
- "9443:9443"
environment:
- LICENSE=accept
- MQ_QMGR_NAME=QM1
healthcheck:
test: ["CMD-SHELL", "chkmqstarted"]
interval: 10s
timeout: 5s
retries: 3

mq-tls:
image: icr.io/ibm-messaging/mq:latest
container_name: ibmmq-test-tls
ports:
- "1415:1414"
environment:
- LICENSE=accept
- MQ_QMGR_NAME=QM2
volumes:
- ./secrets/server.crt:/etc/mqm/pki/keys/mykey/server.crt
- ./secrets/server.key:/etc/mqm/pki/keys/mykey/server.key
- ./secrets/client.crt:/etc/mqm/pki/trust/0/client.crt
healthcheck:
test: ["CMD-SHELL", "chkmqstarted"]
interval: 10s
timeout: 5s
retries: 3
22 changes: 22 additions & 0 deletions ballerina/tests/resources/secrets/client.crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
-----BEGIN CERTIFICATE-----
MIIDtTCCAp2gAwIBAgIUewUKFrcJHN7OpmCzG9cLo3CyZ1UwDQYJKoZIhvcNAQEL
BQAwajELMAkGA1UEBhMCU0wxEDAOBgNVBAgMB1dlc3Rlcm4xEDAOBgNVBAcMB0Nv
bG9tYm8xDTALBgNVBAoMBFdTTzIxFDASBgNVBAsMC0VuZ2luZWVyaW5nMRIwEAYD
VQQDDAlsb2NhbGhvc3QwHhcNMjMxMTEwMDQyNzE0WhcNMzMxMTA3MDQyNzE0WjBq
MQswCQYDVQQGEwJTTDEQMA4GA1UECAwHV2VzdGVybjEQMA4GA1UEBwwHQ29sb21i
bzENMAsGA1UECgwEV1NPMjEUMBIGA1UECwwLRW5naW5lZXJpbmcxEjAQBgNVBAMM
CWxvY2FsaG9zdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALNdmIqa
uUFOLya1p32XyIxCj+6rSEl04ljGpNdGxql8FBkSbBziyD5DaKW/PPF38qrJbi8C
YIC6SwpTUhDQWBAAWDXWa/8upLThDNkuM4+fqeHqikEvSFR7ke34LcmVJFPvRCVy
6TZUlPT5o4QqgiS8hwKxk8AXo57OsUSAsp8YBHDkRBKf5yYzx4GCKN72qVpFpngk
cgHD74mzkXGGol64xt6GKSTB978IcCPXihO2bMXVuNmN70nxbOb31iq15C7X61OD
0WJGq2afSJqc1oGMb1QyL0p0j8sRNx9bI9Zad8IYJrpp1YoM7xc4DB+XBcdypggO
WscCfqUcNpxikgMCAwEAAaNTMFEwHQYDVR0OBBYEFPVIqiWsqVNKiinO2rEaWaRn
2VGnMB8GA1UdIwQYMBaAFPVIqiWsqVNKiinO2rEaWaRn2VGnMA8GA1UdEwEB/wQF
MAMBAf8wDQYJKoZIhvcNAQELBQADggEBABGxxGVgyt2mbkD2Z1iQHGP8vaP+vREd
wT0U6JtEV1ujXHKI2lyDxqeUBJ3p1UU4RiiwJ6WJ3iVqdFrhQShb4A/Gdwc0eEmy
6ok8IauY4I0EHuxFBjgYzJs05xfDsseZRSD4H7bd3oJQX7W6korwfaIP5Cx010nx
b3Xx94YQGZQfY4GtOokrJer+BxzhCoLYTIo9JtcHLC9kPMHwLIU6D9Wjgo8hYrAc
Wn9gOzogwGw7Xfgmnw69DB5kLRW9iKi/uekJhsC9ORfx6iyPfFh4fGY57xIFQo0S
5lB7dyS1QtoRSkAlQpRHtoHQrSYPhiQBukyoHsc0Yipkzhj7as16gbk=
-----END CERTIFICATE-----
28 changes: 28 additions & 0 deletions ballerina/tests/resources/secrets/client.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @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trapqPBOHmOwtiLp1sOv4EHSjoASwxVOD2c1KtFJG8bQPCJpeNpS
imtti4pKdwKBgQDOBM5InoOQJW7urw1mdCxL+4QoqTVr01FywssxtJ2VKolez852
lLY0YHgKUnHYi7g1MFeplxTP6HvAmXNi4NFbQtIkbEIrh3BEE1qSW3eLKp7g+0jK
hYhpFgbUG/0zSYMnmV69ejYx/u0g9fJqi+uR7WdptPB2IXfBFFBBt3JFPQKBgBmq
MY3c1KEvC0hGXhqb8I4mF8jqmOXsUA1CVdTNclo1D2Yv8CrYQ1w6x/PCdcw+3yVP
209C4ULbcrNo9PhmQp4rHIcWiMvAyBaJMpWvz9Zcw2ZV8kTz6wL0rbODUbVH/chX
LYuIMnlDqsng73NkOKzUvhKXsRQRTONDUbC/e9clAoGAWSYzuhGW/GccYaK6Xi/P
A0J/effcneRzQz1FcDA0cBghAxFjoMjJZYC03EZsmwilxgH+C5trmAtLhInl1Djy
OeD4zlroUCI5lOMo2CICQCZ/GaWeRaoiCdTUKXYkEkDx72mdGD89IMZM7bEfotig
1ltJRlZofG/sf7vn5exurAc=
-----END PRIVATE KEY-----
Binary file not shown.
22 changes: 22 additions & 0 deletions ballerina/tests/resources/secrets/server.crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
-----BEGIN CERTIFICATE-----
MIIDtTCCAp2gAwIBAgIUFxjNWUnGQPNZCw70eik8he62nlowDQYJKoZIhvcNAQEL
BQAwajELMAkGA1UEBhMCU0wxEDAOBgNVBAgMB1dlc3Rlcm4xEDAOBgNVBAcMB0Nv
bG9tYm8xDTALBgNVBAoMBFdTTzIxFDASBgNVBAsMC0VuZ2luZWVyaW5nMRIwEAYD
VQQDDAlsb2NhbGhvc3QwHhcNMjMxMTEwMDQyNTU0WhcNMzMxMTA3MDQyNTU0WjBq
MQswCQYDVQQGEwJTTDEQMA4GA1UECAwHV2VzdGVybjEQMA4GA1UEBwwHQ29sb21i
bzENMAsGA1UECgwEV1NPMjEUMBIGA1UECwwLRW5naW5lZXJpbmcxEjAQBgNVBAMM
CWxvY2FsaG9zdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANe/Lf9w
qJ1/12SJNx43xAdEglnay5DiGO7eHxX/WK4FOKILDS4pLtn6sbsKQSLDFokFtpkH
9DMovU62qH6bOHEaLxMX1rOEl5U86TcMx00+qDqcsHzTuw9kxQMvmFyYUtai1jGS
di35hQGucqfKzKjTpu2YyfR8y+AbCwlUNFH0BP6+Xr9zJKDT8PxFv8qRt1TL9BFV
yeFIbmoMrDFfsjLCPEqLckba7ZU5+HfTZQeY2fxaZlXIA/tGSx3VEFCydkH9MF5x
WE02nRRLSSHPbmHL9/vbD0ta45bHwK1qpVpK1MDlgSup4UbXf3dxPNSWDz38THDZ
NV82Z/jH2J3wouECAwEAAaNTMFEwHQYDVR0OBBYEFAm3mzYqk5RUoGBL9ZgEnNIu
ZsYjMB8GA1UdIwQYMBaAFAm3mzYqk5RUoGBL9ZgEnNIuZsYjMA8GA1UdEwEB/wQF
MAMBAf8wDQYJKoZIhvcNAQELBQADggEBALSDdiH306+rzdz1IoP/z1W99UsD3mJ5
NtGyx2W6tuJoUFLBnfg0Y702bLktTVA1lHE+T5vKK+5APRLAu8YfU0mOsY6fKok1
Qv0AIzyB1DqQcoKCbCgWcUgYBfWNAJk9Dieo9eBj6M2Ol04lLw2nA723tFZJvU+H
Jip3r6RKjGMeCGTBM761QdAMLrJ+Z12Qr/5KRkU/6m2UqvLRVtV1OaqSwq6Ms1zl
jN+49wg+5RZH+1iBy3EvfhtyRM0KA4laG+OyLLGZv68wuOF1r7h1XEOr92mD5Apj
1eeGibBuoHjmzE5i8CNsqwjbYUM2LHNgi5lY6k0JQq38IDTkW8h+0LQ=
-----END CERTIFICATE-----
28 changes: 28 additions & 0 deletions ballerina/tests/resources/secrets/server.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwgg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LQOnxc1uJW4ZpwlpusfCIvevEsc53EFriYLlgAOa1b
ESnipdLEp1XZvKoyKL0+21gm7Qbnn+VeVARxgCu31Ow30GHxucOEDVOUC0KtoWUP
Ub7RwTlwxoeaiaDu/rAQLP/gsXnwQsXbom+PnBE+tw502vhQOMpm1IGnwQKBgBsR
hSThvSDUXnoyfFxeTUbBKHZ+5A8RsTURGefHqiacjXvyuuZUsngPQCxoOB+1O221
vZNdKn5w0npHce1WhNMFJXn4TQODiUEAyj/iPoVKdDU86QUwETSe2R7MI15wOnNH
VBj40J3i2vq4vcYWU2i0JDD3VMtpeZBwD/ZRvheRAoGAPjZIffw06EPGOU03acs8
e9/3nqJCrzufB5lA7+3JJ482GOGR0SxwNSByTy247/njL6CKmXtnzq3fMTTZMXTZ
oPiTQorX8GqpaBsHQEh/39/r4QyHqGsap+pAB+VMQ00n0FNrez1F3mkO3ND1w5ap
l3FA7uGaUTbiMZ9i5+Ium1c=
-----END PRIVATE KEY-----
85 changes: 85 additions & 0 deletions ballerina/tests/secure_socket_tests.bal
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved.
//
// WSO2 LLC. licenses this file to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file except
// in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/test;

@test:Config {
groups: ["secureSocket"]
}
function basicPublisherSubscriberSecureSocketTest() returns error? {
QueueManager queueManager = check new (
name = "QM2",
host = "localhost",
port = 1415,
channel = "DEV.APP.SVRCONN",
sslCipherSuite = TLS12ORHIGHER,
secureSocket = {
cert: "./tests/resources/secrets/server.crt",
'key: {
certFile: "./tests/resources/secrets/client.crt",
keyFile: "./tests/resources/secrets/client.key"
}
}
);
Topic subscriber = check queueManager.accessTopic("dev", "DEV.BASE.TOPIC", OPEN_AS_SUBSCRIPTION, MQSO_CREATE);
Topic publisher = check queueManager.accessTopic("dev", "DEV.BASE.TOPIC", OPEN_AS_PUBLICATION, MQOO_OUTPUT);
check publisher->put({
payload: "Hello World".toBytes()
});
Message? message = check subscriber->get();
if message !is () {
test:assertEquals(string:fromBytes(message.payload), "Hello World");
} else {
test:assertFail("Expected a value for message");
}
check subscriber->close();
check publisher->close();
check queueManager.disconnect();
}

@test:Config {
groups: ["secureSocket"]
}
function basicQueueProducerConsumerSecureSocketTest() returns error? {
QueueManager queueManager = check new (
name = "QM2",
host = "localhost",
port = 1415,
channel = "DEV.APP.SVRCONN",
sslCipherSuite = TLS12ORHIGHER,
secureSocket = {
cert: "./tests/resources/secrets/server.crt",
'key: {
certFile: "./tests/resources/secrets/client.crt",
keyFile: "./tests/resources/secrets/client.key"
}
}
);
Queue producer = check queueManager.accessQueue("DEV.QUEUE.1", MQOO_OUTPUT);
Queue consumer = check queueManager.accessQueue("DEV.QUEUE.1", MQOO_INPUT_AS_Q_DEF);
check producer->put({
payload: "Hello World".toBytes()
});
Message? message = check consumer->get();
if message !is () {
test:assertEquals(string:fromBytes(message.payload), "Hello World");
} else {
test:assertFail("Expected a value for message");
}
check producer->close();
check consumer->close();
check queueManager.disconnect();
}
Loading