Skip to content

Commit

Permalink
Merge pull request #3 from vanlooverenkoen/fix/distribution-points
Browse files Browse the repository at this point in the history
Fixed distribution points implementation
  • Loading branch information
vanlooverenkoen authored Dec 30, 2021
2 parents 087786c + 18badcd commit 1e58d8c
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 12 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
# Changelog
## 0.2.9

- Fixed distribution points to use tags instead of indexes

## 0.2.8

- Fixed tag 26 that should be a string

## 0.2.7

- version bump

## 0.2.7b

- updated dart

## 0.2.6

- updated ans1lib

## 0.2.5

- Be more leniant towards unknown OIDs -- treat as Unknown, but do not fail
Expand Down
34 changes: 23 additions & 11 deletions lib/src/extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -570,18 +570,30 @@ class DistributionPoint {
/// reasons [1] ReasonFlags OPTIONAL,
/// cRLIssuer [2] GeneralNames OPTIONAL }
factory DistributionPoint.fromAsn1(ASN1Sequence sequence) {
var name = sequence.elements.isEmpty ? null : toDart(sequence.elements[0]);
var reasons = sequence.elements.length <= 1
? null
: (sequence.elements[1] as ASN1BitString)
.valueBytes()
.map((v) => DistributionPointReason.values[v])
.toList();

var crlIssuer =
sequence.elements.length <= 2 ? null : toDart(sequence.elements[2]);
String? name;
List<DistributionPointReason>? reasons;
String? crlIssuer;
for (final element in sequence.elements) {
switch (element.tag) {
case 0xa0:
name = toDart(element);
break;
case 0xa1:
reasons = ((element as ASN1BitString)
.valueBytes()
.map((v) => DistributionPointReason.values[v])
.toList());
break;
case 0xa2:
crlIssuer = String.fromCharCodes(toDart(element));
break;
}
}
return DistributionPoint(
name: name, reasons: reasons, crlIssuer: crlIssuer);
name: name,
reasons: reasons,
crlIssuer: crlIssuer,
);
}
}

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: x509b
description: Dart library for parsing and working with X.509 certificates.
version: 0.2.8
version: 0.2.9
homepage: https://github.com/jeroentrappers/x509

environment:
Expand Down

0 comments on commit 1e58d8c

Please sign in to comment.