Skip to content

Commit 35ec99c

Browse files
committed
feat(binding-coap): add support for client certificates
1 parent fc3d0a6 commit 35ec99c

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

lib/src/binding_coap/coap_client.dart

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ class _InternalCoapConfig extends CoapConfigDefault {
2626
dtlsCiphers = coapConfig.dtlsCiphers,
2727
dtlsVerify = coapConfig.dtlsVerify,
2828
dtlsWithTrustedRoots = coapConfig.dtlsWithTrustedRoots,
29-
rootCertificates = coapConfig.rootCertificates;
29+
rootCertificates = coapConfig.rootCertificates,
30+
clientCertificateFileName = coapConfig.clientCertificateFileName,
31+
clientKeyFileName = coapConfig.clientKeyFileName,
32+
verifyPrivateKey = coapConfig.verifyPrivateKey;
3033

3134
@override
3235
final int preferredBlockSize;
@@ -42,6 +45,15 @@ class _InternalCoapConfig extends CoapConfigDefault {
4245

4346
@override
4447
final List<Uint8List> rootCertificates;
48+
49+
@override
50+
final String? clientCertificateFileName;
51+
52+
@override
53+
final String? clientKeyFileName;
54+
55+
@override
56+
final bool verifyPrivateKey;
4557
}
4658

4759
coap.PskCredentialsCallback? _createPskCallback(

lib/src/binding_coap/coap_config.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ class CoapConfig {
2222
this.rootCertificates = const [],
2323
this.dtlsWithTrustedRoots = true,
2424
this.dtlsVerify = true,
25+
this.clientKeyFileName,
26+
this.clientCertificateFileName,
27+
this.verifyPrivateKey = false,
2528
});
2629

2730
/// Whether certificates should be verified by OpenSSL.
@@ -57,4 +60,8 @@ class CoapConfig {
5760
///
5861
/// Defaults to 60 seconds.
5962
final Duration multicastDiscoveryTimeout;
63+
64+
final String? clientCertificateFileName;
65+
final String? clientKeyFileName;
66+
final bool verifyPrivateKey;
6067
}

pubspec.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,9 @@ dependencies:
3030
typed_data: ^1.3.2
3131
uri: ^1.0.0
3232
uuid: ^4.2.1
33+
34+
dependency_overrides:
35+
coap:
36+
git:
37+
url: https://github.com/namib-project/coap
38+
ref: client-certificate-support

0 commit comments

Comments
 (0)