x509csr 1.0.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 82

Make X.509 RSA Certificate Signing Requests (CSR). We include helper functions for generating Keypairs and outputting associated PEMs.

This is moderately barebones, contributions welcome.

The CSR PEM can be verified using

openssl req -text -noout -verify -in csr.pem

Usage #

A simple usage example:

import "package:x509csr/x509csr.dart";

import "package:pointycastle/export.dart";
import 'package:asn1lib/asn1lib.dart';

main(List<String> arguments) {
  AsymmetricKeyPair keyPair = rsaGenerateKeyPair();

  ASN1ObjectIdentifier.registerFrequentNames();
  Map<String, String> dn = {
    "CN": "www.davidjanes.com",
    "O": "Consensas",
    "L": "Toronto",
    "ST": "Ontario",
    "C": "CA",
  };

  ASN1Object encodedCSR = makeRSACSR(dn, keyPair.privateKey, keyPair.publicKey);

  print(encodeCSRToPem(encodedCSR));
  print(encodeRSAPublicKeyToPem(keyPair.publicKey));
  print(encodeRSAPrivateKeyToPem(keyPair.privateKey));
}

Features and bugs #

Please file feature requests and bugs at the issue tracker.

See also: #

1.0.2 #

  • Using MD5, not SHA-1 for encoding. This makes PEM verify, though perhaps there's a marker where we can use SHA-256 or something?
  • Documentation

1.0.1 #

  • Add decoding functions for Public and Private Keys

1.0.0 #

  • Initial version

example/x509csr.dart

/*
 *  example/x509csr.dart
 *
 *  David Janes
 *  2019-03-15
 */
import "package:x509csr/x509csr.dart";

import "package:pointycastle/export.dart";
import "package:asn1lib/asn1lib.dart";

main(List<String> arguments) {
  AsymmetricKeyPair keyPair = rsaGenerateKeyPair();

  ASN1ObjectIdentifier.registerFrequentNames();
  Map<String, String> dn = {
    "CN": "www.davidjanes.com",
    "O": "Consensas",
    "L": "Toronto",
    "ST": "Ontario",
    "C": "CA",
  };

  ASN1Object encodedCSR = makeRSACSR(dn, keyPair.privateKey, keyPair.publicKey);

  print(encodeCSRToPem(encodedCSR));
  print(encodeRSAPublicKeyToPem(keyPair.publicKey));
  print(encodeRSAPrivateKeyToPem(keyPair.privateKey));
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  x509csr: ^1.0.2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:x509csr/x509csr.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
70
Health:
Code health derived from static analysis. [more]
89
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
82
Learn more about scoring.

We analyzed this package on Dec 7, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.1
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:x509csr/x509csr.dart.

Health suggestions

Fix lib/crypto.dart. (-11.33 points)

Analysis of lib/crypto.dart reported 24 hints, including:

line 21 col 7: Unnecessary new keyword.

line 23 col 22: Unnecessary new keyword.

line 24 col 16: Unnecessary new keyword.

line 29 col 21: Unnecessary new keyword.

line 29 col 38: Unnecessary new keyword.

Format lib/rsa.dart.

Run dartfmt to format lib/rsa.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
asn1lib ^0.5.7 0.5.14
pointycastle ^1.0.1 1.0.2
Dev dependencies
pedantic ^1.0.0
test ^1.0.0