Skip to content

Commit 0540b11

Browse files
committed
Accept mqtts:// and self-signed brokers
1 parent 13e6ede commit 0540b11

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/entities/dto/create-data-target.dto.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ export class CreateDataTargetDto {
4444
@IsString()
4545
@MaxLength(1024)
4646
@IsNotBlank("url")
47-
@IsUrl({ require_tld: false, require_protocol: true })
47+
@IsUrl({
48+
require_tld: false,
49+
require_protocol: true,
50+
protocols: ["http", "https", "mqtt", "mqtts"],
51+
})
4852
url: string;
4953

5054
@ApiProperty({ required: true, example: 30000 })

src/services/data-targets/mqtt-data-target.service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ export class MqttDataTargetService extends BaseDataTargetService {
3232
password: config.password,
3333
port: config.port,
3434
connectTimeout: config.timeout,
35+
// Accept connection to servers with self-signed certificates
36+
rejectUnauthorized: false,
3537
});
3638
const targetForLogging = `MqttDataTarget(URL '${config.url}', topic '${config.topic}')`;
3739

0 commit comments

Comments
 (0)