tls.go — fiber Source File
Architecture documentation for tls.go, a go file in the fiber codebase. 1 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 5c0551bf_c540_a0e4_2d7e_5dfff598f76c["tls.go"] c0b86961_3ef1_0168_52fc_98627566ed27["bytes"] 5c0551bf_c540_a0e4_2d7e_5dfff598f76c --> c0b86961_3ef1_0168_52fc_98627566ed27 style 5c0551bf_c540_a0e4_2d7e_5dfff598f76c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
package tlstest
import (
"bytes"
"crypto/rand"
"crypto/rsa"
"crypto/tls"
"crypto/x509"
"crypto/x509/pkix"
"encoding/pem"
"errors"
"fmt"
"math/big"
"net"
"time"
)
var errAppendCACert = errors.New("failed to append CA certificate to certificate pool")
// GetTLSConfigs generates TLS configurations for a test server and client that
// trust each other using an in-memory certificate authority.
func GetTLSConfigs() (serverTLSConf, clientTLSConf *tls.Config, err error) { //nolint:nonamedreturns // gocritic unnamedResult prefers naming server and client TLS configurations along with the error
// set up our CA certificate
ca := &x509.Certificate{
SerialNumber: big.NewInt(2021),
Subject: pkix.Name{
Organization: []string{"Fiber"},
Country: []string{"NL"},
Province: []string{""},
Locality: []string{"Amsterdam"},
StreetAddress: []string{"Huidenstraat"},
PostalCode: []string{"1011 AA"},
},
NotBefore: time.Now(),
NotAfter: time.Now().AddDate(10, 0, 0),
IsCA: true,
ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth, x509.ExtKeyUsageServerAuth},
KeyUsage: x509.KeyUsageDigitalSignature | x509.KeyUsageCertSign,
BasicConstraintsValid: true,
}
// create our private and public key
caPrivateKey, err := rsa.GenerateKey(rand.Reader, 4096)
if err != nil {
return nil, nil, fmt.Errorf("generate CA key: %w", err)
}
// create the CA
caBytes, err := x509.CreateCertificate(rand.Reader, ca, ca, &caPrivateKey.PublicKey, caPrivateKey)
if err != nil {
return nil, nil, fmt.Errorf("create CA certificate: %w", err)
}
// pem encode
var caPEM bytes.Buffer
if err = pem.Encode(&caPEM, &pem.Block{
Type: "CERTIFICATE",
Bytes: caBytes,
}); err != nil {
return nil, nil, fmt.Errorf("encode CA cert: %w", err)
// ... (77 more lines)
Domain
Subdomains
Functions
Dependencies
- bytes
Source
Frequently Asked Questions
What does tls.go do?
tls.go is a source file in the fiber codebase, written in go. It belongs to the FiberCore domain, Context subdomain.
What functions are defined in tls.go?
tls.go defines 1 function(s): GetTLSConfigs.
What does tls.go depend on?
tls.go imports 1 module(s): bytes.
Where is tls.go in the architecture?
tls.go is located at internal/tlstest/tls.go (domain: FiberCore, subdomain: Context, directory: internal/tlstest).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free