├── .gitignore
├── doc
├── settings.png
└── settings.svg
├── .vscode
└── settings.json
├── plugin.xml
├── src
└── de
│ └── tobchen
│ └── tobyconnects
│ └── tcssl
│ ├── TrustAllManager.java
│ ├── TrustSomeManager.java
│ ├── TCSSLPropertiesPlugin.java
│ ├── TCSSLServicePlugin.java
│ ├── CertAndKeyManager.java
│ ├── TCSSLPluginProperties.java
│ ├── CertAndKeyStore.java
│ ├── TCSSLConfiguration.java
│ └── TCSSLPanel.java
├── testhelp
├── server.crt
├── unsecure-client.py
├── unsecure-server.py
├── server.key
├── ssl-server.py
├── ssl-client.py
├── client.crt
└── client.key
├── README.md
└── LICENSE
/.gitignore:
--------------------------------------------------------------------------------
1 | lib/
2 | target/
3 | build/
4 | cert/
5 |
--------------------------------------------------------------------------------
/doc/settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tobchen/tc-ssl-plugin/HEAD/doc/settings.png
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "java.server.launchMode": "Standard",
3 | "java.project.sourcePaths": [
4 | "src"
5 | ],
6 | "java.project.referencedLibraries": [
7 | "lib/**/*.jar"
8 | ]
9 | }
--------------------------------------------------------------------------------
/plugin.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 | Toby Connects SSL Plugin
9 | Tobias Heukäufer
10 | 0.3.0
11 | 4.0.1
12 | https://github.com/tobchen
13 | This plugin enables SSL in TCP connectors.
14 |
15 | de.tobchen.tobyconnects.tcssl.TCSSLServicePlugin
16 |
17 |
18 | de.tobchen.tobyconnects.tcssl.TCSSLPropertiesPlugin
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/src/de/tobchen/tobyconnects/tcssl/TrustAllManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 Tobias Heukäufer
3 | *
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at https://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | package de.tobchen.tobyconnects.tcssl;
10 |
11 | import java.security.cert.CertificateException;
12 | import java.security.cert.X509Certificate;
13 |
14 | import javax.net.ssl.X509TrustManager;
15 |
16 | public class TrustAllManager implements X509TrustManager {
17 |
18 | public final static TrustAllManager INSTANCE = new TrustAllManager();
19 |
20 | @Override
21 | public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { }
22 |
23 | @Override
24 | public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { }
25 |
26 | @Override
27 | public X509Certificate[] getAcceptedIssuers() {
28 | return new X509Certificate[0];
29 | }
30 |
31 | }
--------------------------------------------------------------------------------
/testhelp/server.crt:
--------------------------------------------------------------------------------
1 | -----BEGIN CERTIFICATE-----
2 | MIIDizCCAnOgAwIBAgIUHFVCciI4rfCWkTAcXXDTy2QH1SIwDQYJKoZIhvcNAQEL
3 | BQAwVTELMAkGA1UEBhMCREUxDzANBgNVBAgMBkJlcmxpbjEPMA0GA1UEBwwGQmVy
4 | bGluMRAwDgYDVQQKDAdUb2JjaGVuMRIwEAYDVQQDDAlsb2NhbGhvc3QwHhcNMjIw
5 | NjE2MTYzMjU1WhcNMjMwNjE2MTYzMjU1WjBVMQswCQYDVQQGEwJERTEPMA0GA1UE
6 | CAwGQmVybGluMQ8wDQYDVQQHDAZCZXJsaW4xEDAOBgNVBAoMB1RvYmNoZW4xEjAQ
7 | BgNVBAMMCWxvY2FsaG9zdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
8 | AK+o2hxBVY3rS9IEnePdiKNEkEj7VE8csTEPgt1q7W+uAz4spV2vJjdyddrj33EW
9 | aIdoKLj0CxuCi+4mzfw+32ATRsu+G3DAG0+pwWCVpaXazOdqXy3Gym2fTCy7gtEw
10 | YaFiw7WfQxneQuvjX8Pf8Eh98TL0xhJ4SFJljTi8EJu2d0UFTU3W2FyNFlrSl10m
11 | 0sqgsZuITsa9yJxSI9Pki+UjxguyV1KE1wbNdhA1W5QLmV8kOrlX6AhgFEvMwmb6
12 | B2G16PFKQU4rwKpAhEHAVnltE3T5JJwzI+10OzsoVatUCDfBdeRJxYnSCVr9p8MB
13 | rnePYT4x92afmFeyXWHaZq0CAwEAAaNTMFEwHQYDVR0OBBYEFM0R9/6kSm1x/sSR
14 | b3ffImUAxHANMB8GA1UdIwQYMBaAFM0R9/6kSm1x/sSRb3ffImUAxHANMA8GA1Ud
15 | EwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAGRhWvomu1sa4x9gNWDf8xUL
16 | YFJ0jmyUc4plWazEtkBI13C2iCn41NLh9DLYd94+x/e08lWeyd97YGsVFacQe/Vg
17 | RZEVETF3tVqb7HujFv4nyqrqof//QVyHukLXFa8noezsUA6hww81IuBoXbzAkF+n
18 | hkBQrFcFK4O419PKosV/F1bPbxjfHQXXK2kUEdZGZXIPCEngjOpJoSJazePO75iV
19 | sQ2Yw/HKJres7qkzraycCf9irGNxKFl9PTJj8BpxLnvvs7IhzHJ6w5+NTzX9wJ0G
20 | GxvYwx4AMvkvbpqJBbf4UFG2UDaMN5+h3/xet82Mu8C6VlviBo7//zeNHz+G2Gc=
21 | -----END CERTIFICATE-----
22 |
--------------------------------------------------------------------------------
/testhelp/unsecure-client.py:
--------------------------------------------------------------------------------
1 | # Copyright 2022 Tobias Heukäufer
2 | #
3 | # This Source Code Form is subject to the terms of the Mozilla Public
4 | # License, v. 2.0. If a copy of the MPL was not distributed with this
5 | # file, You can obtain one at https://mozilla.org/MPL/2.0/.
6 |
7 | import socket
8 | import sys
9 | from typing import List
10 |
11 |
12 | def send_msg(socket: socket.socket, msg: str):
13 | socket.sendall(bytearray([0x0B, *msg.encode("UTF-8"), 0x1C, 0x0D]))
14 |
15 |
16 | def receive_msg(socket: socket.socket) -> str:
17 | received: List[int] = list()
18 |
19 | read_0x1c = False
20 | read_0x0d = False
21 | while not (read_0x1c and read_0x0d):
22 | data = socket.recv(1024)
23 |
24 | for b in data:
25 | received.append(b)
26 | if b == 0x1C:
27 | read_0x1c = True
28 | elif read_0x1c and b == 0x0D:
29 | read_0x0d = True
30 | else:
31 | read_0x1c = False
32 |
33 | return bytes(received[1:-2]).decode("UTF-8")
34 |
35 |
36 | if len(sys.argv) < 2:
37 | print("Not enough parameters: python3 unsecure-client.py ")
38 | exit(0)
39 |
40 | hostname = "localhost"
41 | port = int(sys.argv[1])
42 |
43 | my_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
44 | my_socket.connect((hostname, port))
45 | send_msg(my_socket, "Hello!")
46 | response = receive_msg(my_socket)
47 | my_socket.close()
48 |
49 | print("Answer: {}".format(response))
50 |
--------------------------------------------------------------------------------
/testhelp/unsecure-server.py:
--------------------------------------------------------------------------------
1 | # Copyright 2022 Tobias Heukäufer
2 | #
3 | # This Source Code Form is subject to the terms of the Mozilla Public
4 | # License, v. 2.0. If a copy of the MPL was not distributed with this
5 | # file, You can obtain one at https://mozilla.org/MPL/2.0/.
6 |
7 | import sys
8 | import socket
9 | from typing import List
10 |
11 |
12 | def send_msg(socket: socket.socket, msg: str):
13 | socket.sendall(bytearray([0x0B, *msg.encode("UTF-8"), 0x1C, 0x0D]))
14 |
15 |
16 | def receive_msg(socket: socket.socket) -> str:
17 | received: List[int] = list()
18 |
19 | read_0x1c = False
20 | read_0x0d = False
21 | while not (read_0x1c and read_0x0d):
22 | data = socket.recv(1024)
23 |
24 | for b in data:
25 | received.append(b)
26 | if b == 0x1C:
27 | read_0x1c = True
28 | elif read_0x1c and b == 0x0D:
29 | read_0x0d = True
30 | else:
31 | read_0x1c = False
32 |
33 | return bytes(received[1:-2]).decode("UTF-8")
34 |
35 |
36 | if len(sys.argv) < 2:
37 | print("Not enough parameters: python3 unsecure-server.py ")
38 | exit(0)
39 |
40 | port = int(sys.argv[1])
41 |
42 | with socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0) as sock:
43 | sock.bind(("localhost", port))
44 | sock.listen()
45 |
46 | conn, addr = sock.accept()
47 |
48 | msg = receive_msg(conn)
49 | send_msg(conn, "You're welcome!")
50 |
51 | conn.close()
52 |
53 | print("From client: {}".format(msg))
54 |
--------------------------------------------------------------------------------
/testhelp/server.key:
--------------------------------------------------------------------------------
1 | -----BEGIN PRIVATE KEY-----
2 | MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCvqNocQVWN60vS
3 | BJ3j3YijRJBI+1RPHLExD4Ldau1vrgM+LKVdryY3cnXa499xFmiHaCi49Asbgovu
4 | Js38Pt9gE0bLvhtwwBtPqcFglaWl2sznal8txsptn0wsu4LRMGGhYsO1n0MZ3kLr
5 | 41/D3/BIffEy9MYSeEhSZY04vBCbtndFBU1N1thcjRZa0pddJtLKoLGbiE7Gvcic
6 | UiPT5IvlI8YLsldShNcGzXYQNVuUC5lfJDq5V+gIYBRLzMJm+gdhtejxSkFOK8Cq
7 | QIRBwFZ5bRN0+SScMyPtdDs7KFWrVAg3wXXkScWJ0gla/afDAa53j2E+Mfdmn5hX
8 | sl1h2matAgMBAAECggEAAWV9PmZCkNtDAgtpWetj77BW2U2uMObQfcxaxPnZo16l
9 | xfPC6MjArAYr666OEy8Ta6gnUrkV8YULKbyDPLMfQXtFv87mFvJgBTUbRXJLG9Nu
10 | d5R/5zRCXba7e0uOUa1pyUeouKPoe6cprwhitYLtPRZLOZV6kaEFKiqGgeH029gH
11 | IJtITAV1vyBoR40Ews819/oneJs/UKbB18wl2+VtdiRHi4H2kGR0HD0mqWHBOqX0
12 | 95oM4k2lhQuOj06E8eL6ixDh7j5RD7IBRdhTkejN7ju94k3caQ4jPQznK0HMPnav
13 | 2xK+qT3jMwdV7abbNdgt4WfCcJq+T9n+ONfWD8kEgQKBgQDeQs3uYXf/2cqJUunz
14 | IPXymny9HO47SfzPdszLzeuzQ/s9IV3rnADrT4fLqf0KPHGqiapzwYS7gDAn5piA
15 | lUK1kdxmJNaxhzu9QBTbc9Dx0EzsaiBRJY67v8Y0jYQJzC2SFM7jd5XXoYOTHqgk
16 | mPGorlfoPnch8eD8y/SOAZHvYQKBgQDKUxb8/i3S0U1oMwCQqkUhcmn/6dt3SKJE
17 | DXLXQ74ywrLDADEB5S+mlbsmc8YFeWn35TDRHOhjt1IFhZhfGfvmLnk0nC0lowkW
18 | ps4YuCGXQKBXLGKMQcwQIdFL4b4XqKSVs5q/ovl8caAMmU6zdwPfqfJEPojBglpV
19 | XIrBUAd2zQKBgGWKlbSDmSQtZwen9rQZ6eNlSvnHHtu9aJ+LwfKWaEllFIIQHW2H
20 | vy/CDOMyDSXBCZkE/feWgMJ8xQNlqWSNTIXRVqTfzaobg2JpxV2hIuNm683SimMo
21 | SnZiHfZidOFZA7TKht6LAs0ZwBfVmLHnofgTdpvm9dxvOf+kWl0KQJbhAoGBAKEl
22 | CLw8Hnc46TRC2wJd+22mWTLRKlGZclRNedhmRkjbtdGGh4IA7rD5tPPtZhzaFUKy
23 | Mu163sT9L8DiJPgqE+3DuhnjAjpl3klCVghuL6LugEauPVeE2GlI5hBQHj1tvpjV
24 | Uj2sKpWpUlZ2jK537ofoLeOZAwdNMXGnoYRSn39JAoGBAJNqnZoCDGTalnuQ06gp
25 | j0YUnuZrKDMkGtM0OD8yY7r1nHSRiHjoyP6DOGUTmtl+e/OnhQaOEJbKg32k+C9y
26 | Vt6i9LkWtObO2NGf81yW7Kpk/kyZkGUNn5sPcPelC7QZiaQJd2WQQ0AEJNSFkenA
27 | 5x36Kxm5IjhrkvG3QRDQfOQl
28 | -----END PRIVATE KEY-----
29 |
--------------------------------------------------------------------------------
/testhelp/ssl-server.py:
--------------------------------------------------------------------------------
1 | # Copyright 2022 Tobias Heukäufer
2 | #
3 | # This Source Code Form is subject to the terms of the Mozilla Public
4 | # License, v. 2.0. If a copy of the MPL was not distributed with this
5 | # file, You can obtain one at https://mozilla.org/MPL/2.0/.
6 |
7 | import sys
8 | import ssl
9 | import socket
10 | from ssl import SSLSocket
11 | from typing import List
12 |
13 |
14 | def send_msg(socket: SSLSocket, msg: str):
15 | socket.sendall(bytearray([0x0B, *msg.encode("UTF-8"), 0x1C, 0x0D]))
16 |
17 |
18 | def receive_msg(socket: SSLSocket) -> str:
19 | received: List[int] = list()
20 |
21 | read_0x1c = False
22 | read_0x0d = False
23 | while not (read_0x1c and read_0x0d):
24 | data = socket.recv(1024)
25 |
26 | for b in data:
27 | received.append(b)
28 | if b == 0x1C:
29 | read_0x1c = True
30 | elif read_0x1c and b == 0x0D:
31 | read_0x0d = True
32 | else:
33 | read_0x1c = False
34 |
35 | return bytes(received[1:-2]).decode("UTF-8")
36 |
37 |
38 | if len(sys.argv) < 3:
39 | print("Not enough parameters: python3 ssl-server.py ")
40 | exit(0)
41 |
42 | port = int(sys.argv[1])
43 |
44 | context = ssl.SSLContext(ssl.PROTOCOL_TLS)
45 | context.load_cert_chain("server.crt", "server.key")
46 | if int(sys.argv[2]) == 1:
47 | context.load_verify_locations("client.crt")
48 | context.verify_mode = ssl.CERT_REQUIRED
49 |
50 | with socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0) as sock:
51 | sock.bind(("localhost", port))
52 | sock.listen()
53 |
54 | with context.wrap_socket(sock, server_side=True) as ssl_sock:
55 | conn, addr = ssl_sock.accept()
56 |
57 | msg = receive_msg(conn)
58 | send_msg(conn, "You're welcome!")
59 |
60 | conn.close()
61 |
62 | print("From client: {}".format(msg))
63 |
--------------------------------------------------------------------------------
/testhelp/ssl-client.py:
--------------------------------------------------------------------------------
1 | # Copyright 2022 Tobias Heukäufer
2 | #
3 | # This Source Code Form is subject to the terms of the Mozilla Public
4 | # License, v. 2.0. If a copy of the MPL was not distributed with this
5 | # file, You can obtain one at https://mozilla.org/MPL/2.0/.
6 |
7 | import sys
8 | import socket
9 | import ssl
10 | from ssl import SSLSocket
11 | from typing import List
12 |
13 |
14 | def send_msg(socket: SSLSocket, msg: str):
15 | socket.sendall(bytearray([0x0B, *msg.encode("UTF-8"), 0x1C, 0x0D]))
16 |
17 |
18 | def receive_msg(socket: SSLSocket) -> str:
19 | received: List[int] = list()
20 |
21 | read_0x1c = False
22 | read_0x0d = False
23 | while not (read_0x1c and read_0x0d):
24 | data = socket.recv(1024)
25 |
26 | for b in data:
27 | received.append(b)
28 | if b == 0x1C:
29 | read_0x1c = True
30 | elif read_0x1c and b == 0x0D:
31 | read_0x0d = True
32 | else:
33 | read_0x1c = False
34 |
35 | return bytes(received[1:-2]).decode("UTF-8")
36 |
37 |
38 | if len(sys.argv) < 3:
39 | print("Not enough parameters: python3 ssl-client.py