x509csr 1.0.2

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]
61
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
81
Learn more about scoring.

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

  • Dart: 2.4.0
  • pana: 0.12.19

Platforms

Detected platforms: Flutter, web, other

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

Health suggestions

Format lib/crypto.dart.

Run dartfmt to format lib/crypto.dart.

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.8
pointycastle ^1.0.1 1.0.1
Dev dependencies
pedantic ^1.0.0
test ^1.0.0