Documentation ¶
Index ¶
- func GetReceiverTLSConfig(cert *SelfSignedCert) (*tls.Config, error)
- func GetSenderTLSConfig(certPEM []byte) *tls.Config
- func ReceiveFromReceiver(addr _net.Addr, timeoutDuration uint) ([]byte, error)
- func SendToSender(certificate *SelfSignedCert, port string, timeoutDuration uint) error
- type SelfSignedCert
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetReceiverTLSConfig ¶
func GetReceiverTLSConfig(cert *SelfSignedCert) (*tls.Config, error)
GetReceiverTLSConfig builds a tls.Config object for the receiver to use when establishing a TLS connection with the sender. It adds the receiver's public/ private key pair to the config's list of certificates.
func GetSenderTLSConfig ¶
GetSenderTLSConfig builds a tls.Config object for the sender to use when establishing a TLS connection with the receiver. It adds the public key of the certificate authority that the receiver created to the config's collection of trusted certificate authorities.
func ReceiveFromReceiver ¶
ReceiveFromReceiver gets a TLS certificate from the receiver at the provided address through a TCP connection.
timeoutDuration is in seconds.
func SendToSender ¶
func SendToSender( certificate *SelfSignedCert, port string, timeoutDuration uint, ) error
SendToSender establishes a TCP connection with the sender and sends a TLS certificate.
timeoutDuration is in seconds.
Types ¶
type SelfSignedCert ¶
type SelfSignedCert struct { // The certificate as PEM-encoded bytes. Bytes []byte // The private key as PEM-encoded bytes. SK []byte }
SelfSignedCert stores an x509 certificate's pieces (the certificate itself as well as a private key) as PEM-encoded bytes.
func GenerateSelfSignedCert ¶
func GenerateSelfSignedCert(ip net.IP) (*SelfSignedCert, error)
GenerateSelfSignedCert creates a self-signed x509 certificate to be used when establishing a TLS connection with the sender. The created certificate is valid for the device with the provided IPv4 address.
It generates a public/private key pair, uses those keys to build an x509 certificate, self-signs that certificate so the sender will trust it, and PEM-encodes that certificate and private key.
Inspired by https://golang.org/src/crypto/tls/generate_cert.go