Skip to content

A simple TLS configuration generator using ECDSA keys and self-signed certificates for Go applications.

License

Notifications You must be signed in to change notification settings

NodePassProject/cert

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 Cannot retrieve latest commit at this time.

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Cert Package

Go Reference License

A simple TLS configuration generator using ECDSA keys and self-signed certificates for Go applications.

Features

  • Easy-to-use TLS configuration generator
  • Uses ECDSA keys with P-256 curve
  • Self-signed certificate generation
  • One-year validity period
  • Custom organization name
  • Automatic random serial number generation

Installation

go get github.com/NodePassProject/cert

Usage

Basic Usage

package main

import (
    "github.com/NodePassProject/cert"
    "log"
    "net/http"
)

func main() {
    // Create a new TLS configuration with organization name
    tlsConfig, err := cert.NewTLSConfig("My Application")
    if err != nil {
        log.Fatalf("Failed to create TLS config: %v", err)
    }
    
    // Create a new HTTP server with TLS
    server := &http.Server{
        Addr:      ":8443",
        TLSConfig: tlsConfig,
        Handler:   yourHandler(),
    }
    
    // Start the server with TLS
    log.Printf("Starting secure server on https://localhost:8443")
    log.Fatal(server.ListenAndServeTLS("", ""))
}

func yourHandler() http.Handler {
    // Your HTTP handler implementation
    return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
        w.Write([]byte("Secure server is running!"))
    })
}

Advanced Configuration

The TLS configuration returned by NewTLSConfig is a standard *tls.Config object that can be further customized:

tlsConfig, err := cert.NewTLSConfig("My Application")
if err != nil {
    log.Fatalf("Failed to create TLS config: %v", err)
}

// Customize the TLS configuration
tlsConfig.MinVersion = tls.VersionTLS12
tlsConfig.CipherSuites = []uint16{
    tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
    tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
}

License

Copyright (c) 2025, NodePassProject. Licensed under the BSD 3-Clause License. See the LICENSE file for details.

About

A simple TLS configuration generator using ECDSA keys and self-signed certificates for Go applications.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages