Fix review comments on snmptrapd nats collector
@@ -37,10 +37,15 @@ my $tornado_writer = async {
if (! defined $client) {
my $ssl_cert_file = getEnvOrDefault("TORNADO_NATS_SSL_CERT_PEM_FILE", "");
my $ssl_cert_key = getEnvOrDefault("TORNADO_NATS_SSL_CERT_KEY", "");
+
+ if ( (!$ssl_cert_file && $ssl_cert_key) || ($ssl_cert_file && !$ssl_cert_key) ) {
+ print "WARN: SSL certificate will NOT be used. You have to provide both the certificate and the key to use it! \n";
+ }
+
my $addr = getEnvOrDefault("TORNADO_NATS_ADDR", "127.0.0.1:4222");
$addr = "nats://$addr";
- if ($ssl_cert_file ne "" && $ssl_cert_key ne "") {
+ if ($ssl_cert_file && $ssl_cert_key) {
print "Start NATS connection to server $addr with SSL certificate [$ssl_cert_file] and key [$ssl_cert_key]\n";
my $socket_args = {
SSL_cert_file => $ssl_cert_file,
