Skip to content

Commit 36a19bc

Browse files
authored
Merge pull request #435 from Telecominfraproject/PKI2-208-Relaxed-security-settings-allow-rtty
Pki2 208 relaxed security settings allow rtty
2 parents 11d7099 + cd5e361 commit 36a19bc

1 file changed

Lines changed: 32 additions & 1 deletion

File tree

src/rttys/RTTYS_server.cpp

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include "Poco/NObserver.h"
1717
#include <Poco/Net/Context.h>
18+
#include <Poco/Net/AcceptCertificateHandler.h>
1819
#include "Poco/Net/SocketNotification.h"
1920
#include "Poco/Net/NetException.h"
2021
#include "Poco/Net/WebSocketImpl.h"
@@ -74,9 +75,32 @@ namespace OpenWifi {
7475
const auto &Cas = MicroServiceConfigPath("ucentral.websocket.host.0.cas", "");
7576
const auto &ClientCasFile = MicroServiceConfigPath("ucentral.websocket.host.0.clientcas", "");
7677

78+
// Read the security mode from websocket configuration
79+
const auto &SecurityMode =
80+
MicroServiceConfigGetString("ucentral.websocket.host.0.security", "relaxed");
81+
82+
// Parse security mode string to verification mode
83+
Poco::Net::Context::VerificationMode VerificationLevel = Poco::Net::Context::VERIFY_RELAXED;
84+
if (SecurityMode == "strict") {
85+
VerificationLevel = Poco::Net::Context::VERIFY_STRICT;
86+
} else if (SecurityMode == "none") {
87+
VerificationLevel = Poco::Net::Context::VERIFY_NONE;
88+
} else if (SecurityMode == "relaxed") {
89+
VerificationLevel = Poco::Net::Context::VERIFY_RELAXED;
90+
} else if (SecurityMode == "once") {
91+
VerificationLevel = Poco::Net::Context::VERIFY_ONCE;
92+
}
93+
94+
// Determine if we should accept all certificates (when security is "none")
95+
bool acceptAllCerts = (VerificationLevel == Poco::Net::Context::VERIFY_NONE);
96+
97+
poco_information(Logger(),
98+
fmt::format("RTTY device socket security mode: {} (acceptAllCerts: {})",
99+
SecurityMode, acceptAllCerts));
100+
77101
Poco::Net::Context::Params P;
78102

79-
P.verificationMode = Poco::Net::Context::VERIFY_ONCE;
103+
P.verificationMode = acceptAllCerts ? Poco::Net::Context::VERIFY_RELAXED : VerificationLevel;
80104
P.verificationDepth = 9;
81105
P.loadDefaultCAs = RootCas.empty();
82106
P.cipherList = "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH";
@@ -109,6 +133,13 @@ namespace OpenWifi {
109133
DeviceSecureContext->disableProtocols(Poco::Net::Context::PROTO_TLSV1 |
110134
Poco::Net::Context::PROTO_TLSV1_1);
111135

136+
// Accept all certificates when security mode is "none"
137+
if (acceptAllCerts) {
138+
DeviceSecureContext->setInvalidCertificateHandler(
139+
Poco::SharedPtr<Poco::Net::InvalidCertificateHandler>(
140+
new Poco::Net::AcceptCertificateHandler(true)));
141+
}
142+
112143
SSL_CTX *SSLCtxDevice = DeviceSecureContext->sslContext();
113144
SSL_CTX_dane_enable(SSLCtxDevice);
114145
Poco::Net::IPAddress Addr(Poco::Net::IPAddress::wildcard(

0 commit comments

Comments
 (0)