shelf_letsencrypt 1.0.0 icon indicating copy to clipboard operation
shelf_letsencrypt: ^1.0.0 copied to clipboard

Let's Encrypt support for the shelf package (free and automatic HTTPS certificate support).

shelf_letsencrypt #

pub package Null Safety Codecov CI GitHub Tag New Commits Last Commits Pull Requests Code size License

shelf_letsencrypt brings support for Let's Encrypt to the shelf package.

Usage #

To use the LetsEncrypt class

import 'dart:io';

import 'package:shelf/shelf.dart';
import 'package:shelf_letsencrypt/shelf_letsencrypt.dart';

void main(List<String> args) async {
  var domain = args[0]; // Domain for the HTTPS certificate.
  var domainEmail = args[1];
  var certificatesDirectory = args.length > 2 ? args[2] : null; // Optional argument.

  certificatesDirectory ??= '/etc/letsencrypt/live'; // Default directory.

  // The Certificate handler, storing at `certificatesDirectory`.
  final certificatesHandler = CertificatesHandlerIO(Directory(certificatesDirectory));

  // The Let's Encrypt integration tool in `staging` mode:
  final LetsEncrypt letsEncrypt = LetsEncrypt(certificatesHandler, production: false);

  // `shelf` Pipeline:
  var pipeline = const Pipeline().addMiddleware(logRequests());
  var handler = pipeline.addHandler(_processRequest);

  var servers = await letsEncrypt.startSecureServer(
    port: 80,
    securePort: 8443,

  var server = servers[0]; // HTTP Server.
  var serverSecure = servers[1]; // HTTPS Server.

  // Enable gzip:
  server.autoCompress = true;
  serverSecure.autoCompress = true;

  print('Serving at http://${}:${server.port}');
  print('Serving at https://${}:${serverSecure.port}');

Response _processRequest(Request request) {
  return Response.ok('Requested: ${request.requestedUri}');

Source #

The official source code is hosted @ GitHub:

Features and bugs #

Please file feature requests and bugs at the issue tracker.

Contribution #

Any help from the open-source community is always welcome and needed:

  • Found an issue?
    • Please fill a bug report with details.
  • Wish a feature?
    • Open a feature request with use cases.
  • Are you using and liking the project?
    • Promote the project: create an article, do a post or make a donation.
  • Are you a developer?
    • Fix a bug and send a pull request.
    • Implement a new feature.
    • Improve the Unit Tests.
  • Have you already helped in any way?
    • Many thanks from me, the contributors and everybody that uses this project!

If you donate 1 hour of your time, you can contribute a lot, because others will do the same, just be part and start with your 1 hour.


  • Add support for multiple HTTPS domains and certificates.
  • Add helper to generate self-signed certificates (for local tests).

Author #

Graciliano M. Passos: gmpassos@GitHub.

License #

Apache License - Version 2.0

pub points


unverified uploader

Let's Encrypt support for the shelf package (free and automatic HTTPS certificate support).

Repository (GitHub)


API reference


Icon for licenses.Apache-2.0 (LICENSE)


acme_client, basic_utils, coverage, dependency_validator, path, shelf


Packages that depend on shelf_letsencrypt