diff --git a/pom.xml b/pom.xml
index d0e5ec8..4c2a8eb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -248,6 +248,11 @@
eclipse-java-formatter.xml
README.adoc
+
+ src/test/resources/create-certs.sh
+ src/test/resources/**.pem
+ src/test/resources/**.srl
+ src/test/resources/**.jks
diff --git a/src/main/java/com/teragrep/aer_02/ManagedRelpConnectionWithMetrics.java b/src/main/java/com/teragrep/aer_02/ManagedRelpConnectionWithMetrics.java
index 94ef9c4..bf973e8 100644
--- a/src/main/java/com/teragrep/aer_02/ManagedRelpConnectionWithMetrics.java
+++ b/src/main/java/com/teragrep/aer_02/ManagedRelpConnectionWithMetrics.java
@@ -130,7 +130,7 @@ public void connect() {
context.close();
connects.inc();
}
- catch (Exception e) {
+ catch (IOException | TimeoutException e) {
System.err
.println(
"Failed to connect to relp server <[" + relpConnection.relpConfig().relpTarget + "]>:<["
diff --git a/src/test/resources/ca-cert.pem b/src/test/resources/ca-cert.pem
new file mode 100644
index 0000000..4102d5e
--- /dev/null
+++ b/src/test/resources/ca-cert.pem
@@ -0,0 +1,20 @@
+-----BEGIN CERTIFICATE-----
+MIIDOTCCAiGgAwIBAgIUfirhFa1VxOAwJVvbjJj/k/RpshswDQYJKoZIhvcNAQEL
+BQAwKzEcMBoGA1UEAwwTdGVzdC1jYS5leGFtcGxlLmNvbTELMAkGA1UEBhMCRkkw
+IBcNMjQxMjIwMTEzNzUxWhgPMjI5ODEwMDUxMTM3NTFaMCsxHDAaBgNVBAMME3Rl
+c3QtY2EuZXhhbXBsZS5jb20xCzAJBgNVBAYTAkZJMIIBIjANBgkqhkiG9w0BAQEF
+AAOCAQ8AMIIBCgKCAQEA4COiDU9fygZNEcqnExU81qr4bO/imHP0XNE2sb7zH5st
++MtEpdpO1eGs/NjmP2TZEV4vCaXpmgW/l5fD+98SIlVJrdEPArvH0FZSwvzwU0gD
+Yn9BcEHFbh4MNMIu/eCEdmXOJU25bcDztMEYsXU2vwVwX5FLHaYXuHt7H1tpSp0P
+jgdFgNeH56cXzvxEaFA4lqwgMxxhLh5YIu02VU1bDOiG4vj05zwRnaXIGk0gbHLl
+OqUJxGXv/vWWSeVWkY47mT8SWEE6gqGuBHfC8PaFvFJg0NxBUFprKmQB4f+oreyk
+f+5zpEYSbKruAGrDbZ/JMHjI+YHizf2bw8IkoOuXsQIDAQABo1MwUTAdBgNVHQ4E
+FgQUog/EY/mpVAqGhQOjyRpPW48jU1wwHwYDVR0jBBgwFoAUog/EY/mpVAqGhQOj
+yRpPW48jU1wwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAH3j9
+dHbiyIty89YI3q6VEsMTqE4rKx/N2iRp3kPLJuc9ZvcK4Lbep49XgIDxH34m3RIb
+Z3jxoHYuQqsm1HXTDaq5mc75na4RP1mqnJH6XdS1qacG+FU1Hxzx8ot1ZjSW1TUo
+xUaDqT1ExvKecQzJL5kiMCUpLRxg73rgtJnSvadxjud0lZ263gmzdkTkFLJBcC5z
+OOBc18GuYTWhhtPJ8V8p5/DMJOeEGRrTxZ8GXLF22uaLoFnBt0vTi53KMY045ARZ
+A359+gS4bps2vICnbDkxwNRNF6W1K+WErAn2aK0eHur+xdly9p5mEFzP2DC38DDL
+59YESQeB7c7DxfGzeA==
+-----END CERTIFICATE-----
diff --git a/src/test/resources/ca-cert.srl b/src/test/resources/ca-cert.srl
new file mode 100644
index 0000000..712d95d
--- /dev/null
+++ b/src/test/resources/ca-cert.srl
@@ -0,0 +1 @@
+4F920BDAD162E2FEED8FA97082C2BB8AE8A1AE45
diff --git a/src/test/resources/ca-key.pem b/src/test/resources/ca-key.pem
new file mode 100644
index 0000000..62f6d78
--- /dev/null
+++ b/src/test/resources/ca-key.pem
@@ -0,0 +1,28 @@
+-----BEGIN PRIVATE KEY-----
+MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDgI6INT1/KBk0R
+yqcTFTzWqvhs7+KYc/Rc0TaxvvMfmy34y0Sl2k7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VQhcAS+
+wlcrPatQab9wmHVY450HqH/PynDATvPe0ATM6AgL/lGRpSaR7SU+nw1qGMAyKAXk
+hXsV0HSk2MISoPmla8Dd+PbMz427C1eTP81VWCVNcuXnoL3mYP5ZdZ1K+QKBgQCJ
+nYp3jJ2ITfTQIZWRypcCAAsGT2pX3Hu/x4mUoYDV3ruRAaFPzDICoPf/In7RiAx2
+U2lAdqevQ3MFQuTK0Nv0LXJS0CvT9hA7t2x5x89cNyxj6iGeQJ+v0S+me+cg8Er4
+lZ85545eWFCZH+BUWRGaUIcDp2359z/i6vOyJAKDpQKBgCG5q4OR8XaicTHxZXCz
+YqAf61W6vH8vnvC4XjwRLgOHPcDxZOIOKMJnWXqklnXeTFHgqYvFMVzjSICwCCSi
+u+Fw8zLO+0Ai1oMCGJbPW6/kRLq/6GTiIYkb5ii5C+DB8wpLIjF8aStOjHhe1KSA
+c7a+QqalB2cFH2MwO4DOYkJy
+-----END PRIVATE KEY-----
diff --git a/src/test/resources/client-cert.pem b/src/test/resources/client-cert.pem
new file mode 100644
index 0000000..d62fa21
--- /dev/null
+++ b/src/test/resources/client-cert.pem
@@ -0,0 +1,19 @@
+-----BEGIN CERTIFICATE-----
+MIIDLDCCAhSgAwIBAgIUT5IL2tFi4v7tj6lwgsK7iuihrkUwDQYJKoZIhvcNAQEL
+BQAwKzEcMBoGA1UEAwwTdGVzdC1jYS5leGFtcGxlLmNvbTELMAkGA1UEBhMCRkkw
+IBcNMjQxMjIwMTEzNzUyWhgPMjA1MjA1MDcxMTM3NTJaMC8xIDAeBgNVBAMMF3Rl
+c3QtY2xpZW50LmV4YW1wbGUuY29tMQswCQYDVQQGEwJGSTCCASIwDQYJKoZIhvcN
+AQEBBQADggEPADCCAQoCggEBAK7xMojjUlbq3Xy0hwh9ek8mFGrLqXM8WahvAJaX
+bVGtz3EskNw5A6PJIuOFvQbeL94SfhlQZ2+Q7b2sHfqE18GgKV8CD9sQv35i6P1B
+cOtZCwI8j2ger1w13xWogLN0RTQ45Xo/1yv2NmLaD9dH2desqV0VZ16HL4RtM0Kg
+RLDCVwhAAZHsju/FFnR566DcuZJmD85n3EqL6D7rmB5l4twBnM6YtlE0WDfLI+9R
+Eerau5DtrZiyUi1vuBtRgzrIYdKHmQE4G7tMuIhrmlt/XNsrMRO+SYiRRWXgLY0q
+jNmberHQEuBVzYw8rAOrfpIxZQNtVjkdCE6vW7weC1nFzE8CAwEAAaNCMEAwHQYD
+VR0OBBYEFKAXmD22jSzYdzoYHRN+k7etYN1dMB8GA1UdIwQYMBaAFKIPxGP5qVQK
+hoUDo8kaT1uPI1NcMA0GCSqGSIb3DQEBCwUAA4IBAQCktTmKoBMtdNHEV/URVujB
+Hq2u1vAxkpoVXVh9X5d/91rMiMsQb5L+e4zOfNCM0re2sswakSfi7dtRAxBPzZxM
+1cfcgkZD4mG4Wzer/K3/GqKGvqn+9je2vgTNHOoC7ngz9XD4vsh2RrWnzzfq3fLX
+3cNkZN7y/1HPz2dfqNd/t8P88tg9uJbtskznY/BrZ8PcLrgrks4GIO+LJ0zcDmZW
+wn57zgIOC8Gwtl/YLkD702785GLSBje790jFufgfoTkj+kZMFzuM9MS2ZFrv+46g
+rOcsQakxMoosJ2NYiNA3plpSC7IPHkbzNdAshnBpEvTNtsuJjRt56Oi0jO2YHhJu
+-----END CERTIFICATE-----
diff --git a/src/test/resources/client-key.pem b/src/test/resources/client-key.pem
new file mode 100644
index 0000000..ade4a97
--- /dev/null
+++ b/src/test/resources/client-key.pem
@@ -0,0 +1,28 @@
+-----BEGIN PRIVATE KEY-----
+MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCu8TKI41JW6t18
+tIcIfXpPJhRqy6lzPFmobwCWl21Rrc9xLJDcOQOjySLjhb0G3i/eEn4ZUGdvkO29
+rB36hNfBoClfAg/bEL9+Yuj9QXDrWQsCPI9oHq9cNd8VqICzdEU0OOV6P9cr9jZi
+2g/XR9nXrKldFWdehy+EbTNCoESwwlcIQAGR7I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GuAWEmQz0+6uhAoGASntt
+jY+DRQ2jaeZKKkK6RJqb9Vao6Y58CfUchLU5nrFcUNKVDpkp/YZ9U/KvPMsfbo3p
+XJFLEtyqoIbLz/Zf+t1mb7sC7axoR1y7nb7MC01MnN3k9Vpu/eFo7BleEoRFalDU
+H4y7sB9A6sCRKvPDlc3+0rOZD7GAtQ8xznaQaQ8CgYB8nRijqBmYpJ05rw51fyrq
+KNruORv7XJkcswBKtelk/AJWnSF7B3/cebA7h//a8dDYmegJDMrXvIr50/qKmDuD
+FEZ+ZATvAXy9fPuO7bYIe4jaKlLJm49H0K0BETK58u2cSuZ9dZ/U/tQwDmDh/J1E
+Ch9ed1trFP4adsIYebnccA==
+-----END PRIVATE KEY-----
diff --git a/src/test/resources/keystore-client.jks b/src/test/resources/keystore-client.jks
new file mode 100644
index 0000000..d3acbba
Binary files /dev/null and b/src/test/resources/keystore-client.jks differ
diff --git a/src/test/resources/keystore-server.jks b/src/test/resources/keystore-server.jks
new file mode 100644
index 0000000..d9997fd
Binary files /dev/null and b/src/test/resources/keystore-server.jks differ
diff --git a/src/test/resources/server-cert.pem b/src/test/resources/server-cert.pem
new file mode 100644
index 0000000..506be7a
--- /dev/null
+++ b/src/test/resources/server-cert.pem
@@ -0,0 +1,19 @@
+-----BEGIN CERTIFICATE-----
+MIIDLDCCAhSgAwIBAgIUT5IL2tFi4v7tj6lwgsK7iuihrkQwDQYJKoZIhvcNAQEL
+BQAwKzEcMBoGA1UEAwwTdGVzdC1jYS5leGFtcGxlLmNvbTELMAkGA1UEBhMCRkkw
+IBcNMjQxMjIwMTEzNzUxWhgPMjA1MjA1MDcxMTM3NTFaMC8xIDAeBgNVBAMMF3Rl
+c3Qtc2VydmVyLmV4YW1wbGUuY29tMQswCQYDVQQGEwJGSTCCASIwDQYJKoZIhvcN
+AQEBBQADggEPADCCAQoCggEBAMVMBtxFeKY7cD4gFBI+Rc0q3qxOk2IgW7PCxehP
+Ni2N1jbUXgbrFS5LY4qabEOgCmmxQmNT2LSGapDpiybnVrQU9Awi6N2cvj6R9Zd0
+LsvZ/1vu2xE2HQ59eU6aZP3gmPwBW0/aMIbVrQrcWP4ViRd9Buunz+RcKkWZk9E+
++t+E9cNyZT8LnQP3h665hFjB78jDtbrP42L7qI/fD6wNh4uC2a+b/i+8Uss3QWQb
+vMXtadI6NT03d8AH0VR8Vct0dhpmgHnAWFwzi3wfi+LobBZWlvvjjggMHSB5EUrc
+wTR8wk2SWOKoqMlsArF3ubCyKjKbgMo2KSmyprOSFAvFTqkCAwEAAaNCMEAwHQYD
+VR0OBBYEFJ9JCSdzSLO/gTIFjrGED956iXZQMB8GA1UdIwQYMBaAFKIPxGP5qVQK
+hoUDo8kaT1uPI1NcMA0GCSqGSIb3DQEBCwUAA4IBAQDcL5EWukzQU4Owg8ql0Uok
+AkcEyxGrn0fsgg5AHO6KBg9gfqdfPVjctA2vI7Pk4LiI8m6XPLWivDbSSD5ZP+ve
+1nXkYuSOx9/TpLQPlQhTwdc+OA8p+D+5Ht9Cvmm1p/70rUdrIDUb3amUKZFLE8Yw
+pNcX+O2w88RqyldHfascBjhqURwlmRXXRAFa2xNkKqExN5G7SJC8wEfWPwcIJudL
+X+1a38dyN2uewSsBZjbGl1dY7Cq+1jW2mJrj8bMJQ9d5N4yejbTIC3+ua954xJKm
+QQWt8PzDDG7HMJ/lydLzLNVUQb8WOn+lWfEzabR56cee8STPwirjF/rBXYY5tpob
+-----END CERTIFICATE-----
diff --git a/src/test/resources/server-key.pem b/src/test/resources/server-key.pem
new file mode 100644
index 0000000..3e3157f
--- /dev/null
+++ b/src/test/resources/server-key.pem
@@ -0,0 +1,28 @@
+-----BEGIN PRIVATE KEY-----
+MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDFTAbcRXimO3A+
+IBQSPkXNKt6sTpNiIFuzwsXoTzYtjdY21F4G6xUuS2OKmmxDoAppsUJjU9i0hmqQ
+6Ysm51a0FPQMIujdnL4+kfWXdC7L2f9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DdIGKpfgMPlNmutVH+AwRSRuUHei/wb22H
+CMriQ5LtDRSiqWrD9FVOsluO+aeCLzKfyTnI9THeE3QqvzC9LZ2UrkFhAoGAc3OQ
+U+sHjS2gyJc7F/VwBltyEP7RDFdRNuftOzEkQEmOy8NJ1hrN2Xh4AApkORshpMbE
+AJFo6JaDkOvG48cD/+Vph0PBh9v4GZlNeK9PQgRJAPTY3iISF1J10zYgFjI448x1
+t4ohyANE3NTzo4KntdRDdOq0C7clhxdau6f49jECgYBYxD8IxrU0lJAmZOeLiJTK
+Tghpxw7UMf4hxLcr7Ciesr4Lk4lRdEgrpjXAp6xKYNgZTsfEjAFlnicHOxZ9hO/8
+9wBiqAon8NU2g5SlMvFc4oFuB38RqWQ1vYaJFsOFlRRC4zl2RyFAX7mD55BHfg3M
+E+Xwn/rJzjSPayoNXz20YQ==
+-----END PRIVATE KEY-----
diff --git a/src/test/resources/truststore.jks b/src/test/resources/truststore.jks
new file mode 100644
index 0000000..b870bc1
Binary files /dev/null and b/src/test/resources/truststore.jks differ