-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #119 from JKRhb/certificate
Add support for root certificates in PEM format
- Loading branch information
Showing
8 changed files
with
1,568 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright (c) 2024 Jan Romann | ||
// SPDX-License-Identifier: MIT | ||
|
||
import "dart:convert"; | ||
import "dart:typed_data"; | ||
|
||
import "package:meta/meta.dart"; | ||
|
||
/// Base class for certificates usable with OpenSSL. | ||
@immutable | ||
sealed class Certificate { | ||
const Certificate(); | ||
|
||
/// The certificate in serialized form. | ||
Uint8List get bytes; | ||
} | ||
|
||
/// A certificate in PEM format. | ||
final class PemCertificate extends Certificate { | ||
/// Creates a new [PemCertificate] from a [_certificateString]. | ||
const PemCertificate(this._certificateString); | ||
|
||
final String _certificateString; | ||
|
||
@override | ||
Uint8List get bytes => utf8.encode(_certificateString); | ||
} | ||
|
||
/// A certificate in DER format. | ||
final class DerCertificate extends Certificate { | ||
/// Creates a new [DerCertificate] from a list of [_bytes]. | ||
const DerCertificate(this._bytes); | ||
|
||
final Uint8List _bytes; | ||
|
||
@override | ||
Uint8List get bytes => _bytes; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.