Documentation ¶
Overview ¶
package cache implements a really primitive cache that associates expiring values with string keys. This cache never clears itself out.
Package keyman provides convenience APIs around Go's built-in crypto APIs.
Index ¶
- Constants
- func MyCopy(src io.Reader, dst io.Writer, ch chan<- error)
- func ParseReq(b []byte) (*http.Request, error)
- func PoolContainingCerts(certs ...string) (*x509.CertPool, error)
- func Start(conf *config.Cfg, tlsConfig *config.TlsConfig, wg *sync.WaitGroup)
- func Transport(conn1, conn2 net.Conn) (err error)
- type Cache
- type Certificate
- func (cert *Certificate) ExpiresBefore(time time.Time) bool
- func (cert *Certificate) PEMEncoded() (pemBytes []byte)
- func (cert *Certificate) PoolContainingCert() *x509.CertPool
- func (cert *Certificate) WriteToDERFile(filename string) (err error)
- func (cert *Certificate) WriteToFile(filename string) (err error)
- func (cert *Certificate) WriteToTempFile() (name string, err error)
- func (cert *Certificate) X509() *x509.Certificate
- type HandlerWrapper
- func (hw *HandlerWrapper) DumpHTTPAndHTTPs(resp http.ResponseWriter, req *http.Request)
- func (hw *HandlerWrapper) FakeCertForName(name string) (cert *tls.Certificate, err error)
- func (hw *HandlerWrapper) Forward(resp http.ResponseWriter, req *http.Request, raddr string)
- func (hw *HandlerWrapper) GenerateCertForClient() (err error)
- func (hw *HandlerWrapper) InterceptHTTPs(resp http.ResponseWriter, req *http.Request)
- func (hw *HandlerWrapper) ServeHTTP(resp http.ResponseWriter, req *http.Request)
- type PrivateKey
- func (key *PrivateKey) Certificate(template *x509.Certificate, issuer *Certificate) (*Certificate, error)
- func (key *PrivateKey) CertificateForKey(template *x509.Certificate, issuer *Certificate, publicKey interface{}) (*Certificate, error)
- func (key *PrivateKey) PEMEncoded() (pemBytes []byte)
- func (key *PrivateKey) TLSCertificateFor(organization string, name string, validUntil time.Time, isCA bool, ...) (cert *Certificate, err error)
- func (key *PrivateKey) WriteToFile(filename string) (err error)
Constants ¶
const ( PEM_HEADER_PRIVATE_KEY = "RSA PRIVATE KEY" PEM_HEADER_PUBLIC_KEY = "RSA PRIVATE KEY" PEM_HEADER_CERTIFICATE = "CERTIFICATE" )
const ( Version = "1.1" ONE_DAY = 24 * time.Hour TWO_WEEKS = ONE_DAY * 14 ONE_MONTH = 1 ONE_YEAR = 1 )
Variables ¶
This section is empty.
Functions ¶
func PoolContainingCerts ¶
PoolContainingCerts constructs a CertPool containing all of the given certs (PEM encoded).
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a cache for binary data
type Certificate ¶
type Certificate struct {
// contains filtered or unexported fields
}
Certificate is a convenience wrapper for x509.Certificate
func LoadCertificateFromFile ¶
func LoadCertificateFromFile(filename string) (*Certificate, error)
LoadCertificateFromFile loads a Certificate from a PEM-encoded file
func LoadCertificateFromPEMBytes ¶
func LoadCertificateFromPEMBytes(pemBytes []byte) (*Certificate, error)
LoadCertificateFromPEMBytes loads a Certificate from a byte array in PEM format
func LoadCertificateFromX509 ¶
func LoadCertificateFromX509(cert *x509.Certificate) (*Certificate, error)
LoadCertificateFromX509 loads a Certificate from an x509.Certificate
func (*Certificate) ExpiresBefore ¶
func (cert *Certificate) ExpiresBefore(time time.Time) bool
func (*Certificate) PEMEncoded ¶
func (cert *Certificate) PEMEncoded() (pemBytes []byte)
PEMEncoded encodes the Certificate in PEM
func (*Certificate) PoolContainingCert ¶
func (cert *Certificate) PoolContainingCert() *x509.CertPool
PoolContainingCert creates a pool containing this cert.
func (*Certificate) WriteToDERFile ¶
func (cert *Certificate) WriteToDERFile(filename string) (err error)
WriteToDERFile writes the DER-encoded Certificate to a file.
func (*Certificate) WriteToFile ¶
func (cert *Certificate) WriteToFile(filename string) (err error)
WriteToFile writes the PEM-encoded Certificate to a file.
func (*Certificate) WriteToTempFile ¶
func (cert *Certificate) WriteToTempFile() (name string, err error)
func (*Certificate) X509 ¶
func (cert *Certificate) X509() *x509.Certificate
X509 returns the x509 certificate underlying this Certificate
type HandlerWrapper ¶
func InitConfig ¶
func (*HandlerWrapper) DumpHTTPAndHTTPs ¶
func (hw *HandlerWrapper) DumpHTTPAndHTTPs(resp http.ResponseWriter, req *http.Request)
func (*HandlerWrapper) FakeCertForName ¶
func (hw *HandlerWrapper) FakeCertForName(name string) (cert *tls.Certificate, err error)
func (*HandlerWrapper) Forward ¶
func (hw *HandlerWrapper) Forward(resp http.ResponseWriter, req *http.Request, raddr string)
func (*HandlerWrapper) GenerateCertForClient ¶
func (hw *HandlerWrapper) GenerateCertForClient() (err error)
func (*HandlerWrapper) InterceptHTTPs ¶
func (hw *HandlerWrapper) InterceptHTTPs(resp http.ResponseWriter, req *http.Request)
func (*HandlerWrapper) ServeHTTP ¶
func (hw *HandlerWrapper) ServeHTTP(resp http.ResponseWriter, req *http.Request)
type PrivateKey ¶
type PrivateKey struct {
// contains filtered or unexported fields
}
PrivateKey is a convenience wrapper for rsa.PrivateKey
func GeneratePK ¶
func GeneratePK(bits int) (key *PrivateKey, err error)
GeneratePK generates a PrivateKey with a specified size in bits.
func LoadPKFromFile ¶
func LoadPKFromFile(filename string) (key *PrivateKey, err error)
LoadPKFromFile loads a PEM-encoded PrivateKey from a file
func (*PrivateKey) Certificate ¶
func (key *PrivateKey) Certificate(template *x509.Certificate, issuer *Certificate) (*Certificate, error)
Certificate() generates a certificate for the Public Key of the given PrivateKey based on the given template and signed by the given issuer. If issuer is nil, the generated certificate is self-signed.
func (*PrivateKey) CertificateForKey ¶
func (key *PrivateKey) CertificateForKey(template *x509.Certificate, issuer *Certificate, publicKey interface{}) (*Certificate, error)
CertificateForKey() generates a certificate for the given Public Key based on the given template and signed by the given issuer. If issuer is nil, the generated certificate is self-signed.
func (*PrivateKey) PEMEncoded ¶
func (key *PrivateKey) PEMEncoded() (pemBytes []byte)
PEMEncoded encodes the PrivateKey in PEM
func (*PrivateKey) TLSCertificateFor ¶
func (key *PrivateKey) TLSCertificateFor( organization string, name string, validUntil time.Time, isCA bool, issuer *Certificate) (cert *Certificate, err error)
TLSCertificateFor generates a certificate useful for TLS use based on the given parameters. These certs are usable for key encipherment and digital signatures.
organization: the org name for the cert. name: used as the common name for the cert. If name is an IP address, it is also added as an IP SAN. validUntil: time at which certificate expires isCA: whether or not this cert is a CA issuer: the certificate which is issuing the new cert. If nil, the new cert will be a self-signed CA certificate.
func (*PrivateKey) WriteToFile ¶
func (key *PrivateKey) WriteToFile(filename string) (err error)
WriteToFile writes the PEM-encoded PrivateKey to the given file