Documentation
¶
Index ¶
- func BuildP12(certBytes, keyBytes []byte, password string, ca ...[]byte) ([]byte, error)
- func BuildP12ForGM(certBytes, keyBytes []byte, password string, ca ...[]byte) ([]byte, error)
- func CertificateRequestText(csr *x509.CertificateRequest) (string, error)
- func CertificateText(cert *x509.Certificate) (string, error)
- func Decrypt(r string, priPem []byte) ([]byte, error)
- func Encrypt(raw []byte, pemBytes []byte) (string, error)
- func GenerateCA(opts ...CertOption) ([]byte, []byte, error)
- func GenerateCRL(ca, key []byte, revokingCert []byte, existedRevoked ...pkix.RevokedCertificate) ([]byte, error)
- func GenerateCRLWithExistedList(ca, key []byte, existedRevoked ...pkix.RevokedCertificate) ([]byte, error)
- func GenerateClientCert(caCertPEM, caKeyPEM []byte, opts ...CertOption) ([]byte, []byte, error)
- func GenerateGMSelfSignedCertKey(commonName string) ([]byte, []byte, error)
- func GeneratePrivateAndPublicKeyPEM() (pri []byte, pub []byte, _ error)
- func GeneratePrivateAndPublicKeyPEMWithPrivateFormatter(t string) (pri []byte, pub []byte, _ error)
- func GeneratePrivateAndPublicKeyPEMWithPrivateFormatterWithSize(t string, size int) (pri []byte, pub []byte, _ error)
- func GenerateSelfSignedCertKey(host string, alternateIPs []net.IP, alternateDNS []string) ([]byte, []byte, error)
- func GenerateSelfSignedCertKeyWithCommonName(commonName, host string, alternateIPs []net.IP, alternateDNS []string) ([]byte, []byte, error)
- func GenerateSelfSignedCertKeyWithCommonNameEx(commonName, org, host string, alternateIPs []net.IP, alternateDNS []string, ...) ([]byte, []byte, error)
- func GenerateSelfSignedCertKeyWithCommonNameWithPrivateKeyWithOrg(commonName, org, host string, alternateIPs []net.IP, alternateDNS []string, ...) ([]byte, []byte, error)
- func GenerateServerCert(caCertPEM, caKeyPEM []byte, opts ...CertOption) ([]byte, []byte, error)
- func GetRSAPrivateKey(raw []byte) (*rsa.PrivateKey, error)
- func GetRSAPubKey(raw []byte) (*rsa.PublicKey, error)
- func GetX509GMMutualAuthClientTlsConfig(clientCrt, clientPriv []byte, caCrts ...[]byte) (*gmtls.Config, error)
- func GetX509GMServerTlsConfigWithAuth(ca, server, serverKey []byte, auth bool) (*gmtls.Config, error)
- func GetX509GMServerTlsConfigWithOnly(ca, server, serverKey []byte, auth bool) (*gmtls.Config, error)
- func GetX509MutualAuthClientTlsConfig(clientCrt, clientPriv []byte, caCrts ...[]byte) (*tls.Config, error)
- func GetX509MutualAuthGoClientTlsConfig(clientCrt, clientPriv []byte, caCrts ...[]byte) (*tls.Config, error)
- func GetX509MutualAuthServerTlsConfig(caPemRaw, serverCrt, keyPriv []byte) (*tls.Config, error)
- func GetX509ServerTlsConfig(caPemRaw, serverCrt, keyPriv []byte) (*tls.Config, error)
- func GetX509ServerTlsConfigWithAuth(caPemRaw, serverCrt, keyPriv []byte, auth bool) (*tls.Config, error)
- func LoadP12ToPEM(p12Data []byte, password string) (certBytes, keyBytes []byte, ca [][]byte, err error)
- func MergeBlock(raw []string) ([]byte, error)
- func NewDefaultTLSServer(conn net.Conn) *tls.Conn
- func ParseCertAndPriKeyAndPool(clientCrt, clientPriv []byte, caCrts ...[]byte) (tls.Certificate, *x509gm.CertPool, error)
- func ParseCertAndPriKeyAndPoolForGM(clientCrt, clientPriv []byte, caCrts ...[]byte) (gmtls.Certificate, *x509gm.CertPool, error)
- func ParseCertificate(pemBytes []byte) (*x509.Certificate, error)
- func ParseGMPEMCertificate(ca []byte) (*x509gm.Certificate, error)
- func ParsePEMCRL(ca []byte) ([]pkix.RevokedCertificate, error)
- func ParsePEMCRLRaw(ca []byte) (*pkix.CertificateList, error)
- func ParsePEMCert(crt []byte) (*x509.Certificate, error)
- func ParsePEMCertificate(ca []byte) (*x509.Certificate, error)
- func ParsePEMCertificateAndKey(ca, key []byte) (*x509.Certificate, *rsa.PrivateKey, error)
- func ParsePEMCertificateAndKeyForGM(ca, key []byte) (*x509gm.Certificate, *sm2.PrivateKey, error)
- func ParsePrivateKey(pemBytes []byte) (crypto.Signer, error)
- func ParseRsaPrivateKeyFromDerBytes(derBytes []byte) (*rsa.PrivateKey, error)
- func ParseRsaPrivateKeyFromPemBlock(block *pem.Block) (*rsa.PrivateKey, error)
- func ParseRsaPublicKeyFromDerBytes(derBytes []byte) (*rsa.PublicKey, error)
- func ParseRsaPublicKeyFromPemBlock(block *pem.Block) (*rsa.PublicKey, error)
- func PemPkcs1v15Decrypt(pemPriBytes []byte, data interface{}) ([]byte, error)
- func PemPkcs1v15Encrypt(pemBytes []byte, data interface{}) ([]byte, error)
- func PemPkcsOAEPDecrypt(pemPriBytes []byte, data interface{}) ([]byte, error)
- func PemPkcsOAEPEncrypt(raw []byte, data interface{}) ([]byte, error)
- func PemSignSha256WithRSA(pemBytes []byte, data interface{}) ([]byte, error)
- func PemVerifySignSha256WithRSA(pemBytes []byte, originData any, sign []byte) error
- func Pkcs1v15Decrypt(raw []byte, data interface{}) ([]byte, error)
- func Pkcs1v15Encrypt(raw []byte, data interface{}) ([]byte, error)
- func PkcsOAEPDecrypt(raw []byte, data interface{}) ([]byte, error)
- func PkcsOAEPDecryptWithHash(raw []byte, data interface{}, hashFunc hash.Hash) ([]byte, error)
- func PkcsOAEPEncrypt(raw []byte, data interface{}) ([]byte, error)
- func PkcsOAEPEncryptWithHash(raw []byte, data interface{}, hashFunc hash.Hash) ([]byte, error)
- func RSAGenerateKeyPair(bitSize int) ([]byte, []byte, error)
- func SM2GenerateKeyPair() ([]byte, []byte, error)
- func SelfSignCACertificateAndPrivateKey(common string, opts ...SelfSignConfigOpt) ([]byte, []byte, error)
- func SignClientCrtNKey(ca, key []byte) ([]byte, []byte, error)
- func SignClientCrtNKeyEx(ca []byte, key []byte, commonName string, auth bool) (cert []byte, sKey []byte, _ error)
- func SignClientCrtNKeyWithParams(ca, key []byte, cn string, notAfter time.Time, x509Auth bool) (cert []byte, skey []byte, _ error)
- func SignClientCrtNKeyWithoutAuth(ca, key []byte) ([]byte, []byte, error)
- func SignGMClientCrtNKeyWithParams(ca []byte, privateKey []byte, cn string, notAfter time.Time, auth bool) ([]byte, []byte, error)
- func SignGMServerCrtNKeyWithParams(ca []byte, privateKey []byte, cn string, notAfter time.Time, auth bool) ([]byte, []byte, error)
- func SignServerCrtNKey(ca []byte, key []byte) (cert []byte, sKey []byte, _ error)
- func SignServerCrtNKeyEx(ca []byte, key []byte, commonName string, auth bool) (cert []byte, sKey []byte, _ error)
- func SignServerCrtNKeyWithParams(ca []byte, key []byte, cn string, notAfter time.Time, authClient bool) (cert []byte, sKey []byte, _ error)
- func SignServerCrtNKeyWithoutAuth(ca []byte, key []byte) (cert []byte, sKey []byte, _ error)
- func SplitBlock(raw []byte, blockSize int) ([]string, error)
- type CertConfig
- type CertOption
- func WithAlternativeDNS(dnsNames ...string) CertOption
- func WithAlternativeIPStrings(ipStrings ...string) CertOption
- func WithAlternativeIPs(ips ...net.IP) CertOption
- func WithCommonName(cn string) CertOption
- func WithCountry(country string) CertOption
- func WithExtKeyUsage(usage ...x509.ExtKeyUsage) CertOption
- func WithKeyUsage(usage x509.KeyUsage) CertOption
- func WithLocality(locality string) CertOption
- func WithNotAfter(t time.Time) CertOption
- func WithNotBefore(t time.Time) CertOption
- func WithOrganization(org string) CertOption
- func WithOrganizationalUnit(ou string) CertOption
- func WithPrivateKey(key crypto.Signer) CertOption
- func WithPrivateKeyFromBytes(key []byte) CertOption
- func WithPrivateKeyFromFile(path string) CertOption
- func WithProvince(province string) CertOption
- func WithValidity(duration time.Duration) CertOption
- type HandshakeClientHello
- type HandshakeClientHelloExt
- type SelfSignConfig
- type SelfSignConfigOpt
- func WithSelfSign_EnableAuth(b bool) SelfSignConfigOpt
- func WithSelfSign_NotAfter(t time.Time) SelfSignConfigOpt
- func WithSelfSign_NotBefore(t time.Time) SelfSignConfigOpt
- func WithSelfSign_Organization(s string) SelfSignConfigOpt
- func WithSelfSign_PrivateKey(p *rsa.PrivateKey) SelfSignConfigOpt
- func WithSelfSign_SignTo(s ...string) SelfSignConfigOpt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildP12ForGM ¶
func CertificateRequestText ¶
func CertificateRequestText(csr *x509.CertificateRequest) (string, error)
CertificateRequestText returns a human-readable string representation of the certificate request csr. The format is similar (but not identical) to the OpenSSL way of printing certificates.
func CertificateText ¶
func CertificateText(cert *x509.Certificate) (string, error)
CertificateText returns a human-readable string representation of the certificate cert. The format is similar (but not identical) to the OpenSSL way of printing certificates.
func GenerateCA ¶
func GenerateCA(opts ...CertOption) ([]byte, []byte, error)
GenerateCA 创建一个新的自签名 CA 证书和私钥。 返回 PEM 编码的证书和私钥。
func GenerateCRL ¶
func GenerateCRLWithExistedList ¶
func GenerateCRLWithExistedList(ca, key []byte, existedRevoked ...pkix.RevokedCertificate) ([]byte, error)
func GenerateClientCert ¶
func GenerateClientCert(caCertPEM, caKeyPEM []byte, opts ...CertOption) ([]byte, []byte, error)
GenerateClientCert 使用给定的 CA 签发一个客户端证书。 caCertPEM 和 caKeyPEM 是 PEM 编码的 CA 证书和私钥。
func GeneratePrivateAndPublicKeyPEMWithPrivateFormatter ¶ added in v1.2.2
func GeneratePrivateAndPublicKeyPEMWithPrivateFormatterWithSize ¶ added in v1.2.3
func GenerateSelfSignedCertKeyWithCommonNameWithPrivateKeyWithOrg ¶ added in v1.2.3
func GenerateServerCert ¶
func GenerateServerCert(caCertPEM, caKeyPEM []byte, opts ...CertOption) ([]byte, []byte, error)
GenerateServerCert 使用给定的 CA 签发一个服务器证书。 caCertPEM 和 caKeyPEM 是 PEM 编码的 CA 证书和私钥。
func GetRSAPrivateKey ¶
func GetRSAPrivateKey(raw []byte) (*rsa.PrivateKey, error)
func GetX509GMServerTlsConfigWithOnly ¶ added in v1.3.1
func GetX509ServerTlsConfig ¶
func LoadP12ToPEM ¶ added in v1.2.7
func MergeBlock ¶
func ParseCertificate ¶
func ParseCertificate(pemBytes []byte) (*x509.Certificate, error)
ParseCertificate 从 PEM 编码的字节中解析 x509.Certificate。
func ParseGMPEMCertificate ¶
func ParseGMPEMCertificate(ca []byte) (*x509gm.Certificate, error)
func ParsePEMCRL ¶
func ParsePEMCRL(ca []byte) ([]pkix.RevokedCertificate, error)
func ParsePEMCRLRaw ¶
func ParsePEMCRLRaw(ca []byte) (*pkix.CertificateList, error)
func ParsePEMCert ¶
func ParsePEMCert(crt []byte) (*x509.Certificate, error)
func ParsePEMCertificate ¶
func ParsePEMCertificate(ca []byte) (*x509.Certificate, error)
func ParsePEMCertificateAndKey ¶
func ParsePEMCertificateAndKey(ca, key []byte) (*x509.Certificate, *rsa.PrivateKey, error)
func ParsePEMCertificateAndKeyForGM ¶
func ParsePEMCertificateAndKeyForGM(ca, key []byte) (*x509gm.Certificate, *sm2.PrivateKey, error)
func ParsePrivateKey ¶
ParsePrivateKey 从 PEM 编码的字节中解析 crypto.Signer(私钥)。 它会尝试解析 PKCS#8 和 PKCS#1 格式的私钥。
func ParseRsaPrivateKeyFromDerBytes ¶
func ParseRsaPrivateKeyFromDerBytes(derBytes []byte) (*rsa.PrivateKey, error)
func ParseRsaPrivateKeyFromPemBlock ¶
func ParseRsaPrivateKeyFromPemBlock(block *pem.Block) (*rsa.PrivateKey, error)
func PemPkcs1v15Decrypt ¶
func PemPkcs1v15Encrypt ¶
func PemPkcsOAEPDecrypt ¶ added in v1.2.2
func PemPkcsOAEPEncrypt ¶ added in v1.2.2
func PemSignSha256WithRSA ¶
SignSHA256WithRSA 使用RSA私钥对数据进行SHA256签名,返回签名与错误 Example: ``` pemBytes = string(`-----BEGIN PRIVATE KEY----- MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDZz5Zz3z3z3z3z ... -----END PRIVATE KEY-----`) signBytes, err := tls.SignSHA256WithRSA(pemBytes, "hello") die(err) signString = string(signBytes) ```
func PemVerifySignSha256WithRSA ¶
SignVerifySHA256WithRSA 使用RSA公钥对数据进行SHA256签名验证,返回错误 Example: ``` pemBytes = string(`-----BEGIN PUBLIC KEY----- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs1pvFYNQpPSPbshg6F7Z ... -----END PUBLIC KEY-----`) err := tls.PemVerifySignSha256WithRSA(pemBytes, "hello", signBytes) die(err) ```
func Pkcs1v15Decrypt ¶
DecryptWithPkcs1v15/RSADecryptWithPKCS1v15 使用 RSA私钥 和 PKCS#1 v1.5填充方式 解密给定的密文。 参数 raw 表示 RSA 私钥,支持以下格式:
- DER 编码的私钥(raw ASN.1 DER 字节流)
- Base64 编码的 DER 格式(自动解码)
- PEM 编码(包括带有 "-----BEGIN PRIVATE KEY-----" 或 "-----BEGIN RSA PRIVATE KEY-----" 的块)
- Base64 编码的 PEM 格式(自动解码)
参数 data 是被加密后的数据(密文) 返回值是解密得到的原始明文,如果失败则返回错误。
Example: ```
raw := ` -----BEGIN PRIVATE KEY----- MIIEvQIBADANBgkqhkiG9w0BAQEFAASC...(略) -----END PRIVATE KEY----- ` plaintext, err := DecryptWithPkcs1v15(raw, encryptedData) plaintext, err := RSADecryptWithPKCS1v15(raw, encryptedData)
```
func Pkcs1v15Encrypt ¶
EncryptWithPkcs1v15/RSAEncryptWithPKCS1v15 使用 RSA 公钥和 PKCS#1 v1.5 填充方式对给定数据进行加密。
参数 raw 表示 RSA 公钥,支持以下格式:
- DER 编码的公钥(raw ASN.1 DER 字节流)
- Base64 编码的 DER 格式(自动解码)
- PEM 编码(例如 "-----BEGIN PUBLIC KEY-----" 或 "-----BEGIN RSA PUBLIC KEY-----" 块)
- Base64 编码的 PEM 格式(自动解码)
参数 data 是要加密的明文数据,可以是 []byte、string 或其他可转换为字节数组的类型。 返回值是加密后的密文(字节切片),如果加密失败则返回错误。
Example: ```
raw := ` -----BEGIN PUBLIC KEY----- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAn...(略) -----END PUBLIC KEY----- ` ciphertext, err := EncryptWithPkcs1v15(raw, "hello world") ciphertext, err := RSAEncryptWithPKCS1v15(raw, "hello world")
```
func PkcsOAEPDecrypt ¶
RSADecryptWithOAEP 使用 RSA私钥 和 RSA-OAEP 填充方式解密给定的密文。 参数 raw 表示 RSA 私钥,支持以下格式:
- DER 编码的私钥(raw ASN.1 DER 字节流)
- Base64 编码的 DER 格式(自动解码)
- PEM 编码(包括带有 "-----BEGIN PRIVATE KEY-----" 或 "-----BEGIN RSA PRIVATE KEY-----" 的块)
- Base64 编码的 PEM 格式(自动解码)
参数 data 是加密后的数据(密文),可以是 []byte 或 base64 字符串等支持类型。 返回值是解密得到的原始明文,如果失败则返回错误。
示例:
raw := ` -----BEGIN PRIVATE KEY----- MIIEvQIBADANBgkqhkiG9w0BAQEFAASC...(略) -----END PRIVATE KEY----- ` plaintext, err := Pkcs1v15Decrypt([]byte(raw), encryptedData)
func PkcsOAEPDecryptWithHash ¶
func PkcsOAEPEncrypt ¶
RSAEncryptWithOAEP 使用 RSA 公钥和 OAEP 填充方式对给定数据进行加密。
参数 raw 表示 RSA 公钥,支持以下格式:
- DER 编码的公钥(raw ASN.1 DER 字节流)
- Base64 编码的 DER 格式(自动解码)
- PEM 编码(例如 "-----BEGIN PUBLIC KEY-----" 或 "-----BEGIN RSA PUBLIC KEY-----" 块)
- Base64 编码的 PEM 格式(自动解码)
参数 data 是要加密的明文数据,可以是 []byte、string 或其他可转换为字节数组的类型。 返回值是加密后的密文(字节切片),如果加密失败则返回错误。
Example: ```
raw := ` -----BEGIN PUBLIC KEY----- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAn...(略) -----END PUBLIC KEY----- ` ciphertext, err := RSAEncryptWithOAEP(raw, "hello world")
```
func PkcsOAEPEncryptWithHash ¶
func RSAGenerateKeyPair ¶
GenerateRSAKeyPair 根据给定的bit大小生成RSA公私钥对,返回PEM格式公钥和私钥与错误 Example: ``` pub, pri, err := tls.GenerateRSAKeyPair(2048) ```
func SM2GenerateKeyPair ¶
GenerateSM2KeyPair 生成SM2公私钥对,返回PEM格式公钥和私钥与错误 Example: ``` pub, pri, err := tls.GenerateSM2KeyPair() ```
func SelfSignCACertificateAndPrivateKey ¶
func SelfSignCACertificateAndPrivateKey(common string, opts ...SelfSignConfigOpt) ([]byte, []byte, error)
func SignClientCrtNKey ¶
SignX509ClientCertAndKey 根据给定的CA证书和私钥,生成客户端证书和密钥,返回PEM格式的客户端证书和密钥与错误 Example: ``` ca, key, err = tls.GenerateRootCA("yaklang.io") cert, sKey, err = tls.SignX509ClientCertAndKey(ca, key) ```
func SignClientCrtNKeyEx ¶
func SignClientCrtNKeyWithoutAuth ¶ added in v1.3.1
SignClientCertAndKey 根据给定的CA证书和私钥,生成不包含认证的客户端证书和密钥,返回PEM格式的客户端证书和密钥与错误 Example: ``` ca, key, err = tls.GenerateRootCA("yaklang.io") cert, sKey, err = tls.SignClientCertAndKey(ca, key) ```
func SignServerCrtNKey ¶
SignX509ServerCertAndKey 根据给定的CA证书和私钥,生成服务器证书和密钥,返回PEM格式的服务器证书和密钥与错误 Example: ``` ca, key, err = tls.GenerateRootCA("yaklang.io") cert, sKey, err = tls.SignX509ServerCertAndKey(ca, key) ```
func SignServerCrtNKeyEx ¶
func SignServerCrtNKeyWithoutAuth ¶ added in v1.3.1
SignServerCertAndKey 根据给定的CA证书和私钥,生成不包含认证的服务器证书和密钥,返回PEM格式的服务器证书和密钥与错误 Example: ``` ca, key, err = tls.GenerateRootCA("yaklang.io") cert, sKey, err = tls.SignServerCertAndKey(ca, key) ```
Types ¶
type CertConfig ¶
type CertConfig struct {
// Subject (主题) 信息
Country string
Province string
Locality string
Organization string
OrganizationalUnit string
CommonName string
// 有效期
NotBefore time.Time
NotAfter time.Time
// 主体备用名称 (SAN)
AlternativeDNS []string
AlternativeIPs []net.IP
// 密钥用途
KeyUsage x509.KeyUsage
ExtKeyUsage []x509.ExtKeyUsage
// 要用于证书的私钥。如果为 nil, 将会自动生成一个新的 2048 位 RSA 私钥。
PrivateKey crypto.Signer
}
CertConfig 包含了生成证书所需的所有可配置属性。
type CertOption ¶
type CertOption func(*CertConfig)
CertOption 是一个用于配置 CertConfig 的函数类型。
func WithAlternativeDNS ¶
func WithAlternativeDNS(dnsNames ...string) CertOption
WithAlternativeDNS 添加一个或多个 DNS 备用名称 (SAN)。
func WithAlternativeIPStrings ¶
func WithAlternativeIPStrings(ipStrings ...string) CertOption
WithAlternativeIPStrings 添加一个或多个字符串格式的 IP 备用名称 (SAN)。 无效的 IP 字符串将被忽略。
func WithAlternativeIPs ¶
func WithAlternativeIPs(ips ...net.IP) CertOption
WithAlternativeIPs 添加一个或多个 IP 备用名称 (SAN)。
func WithCommonName ¶
func WithCommonName(cn string) CertOption
WithCommonName 设置证书的通用名称 (Common Name)。
func WithCountry ¶
func WithCountry(country string) CertOption
func WithExtKeyUsage ¶
func WithExtKeyUsage(usage ...x509.ExtKeyUsage) CertOption
WithExtKeyUsage 设置证书的扩展密钥用途 (Extended Key Usage)。
func WithKeyUsage ¶
func WithKeyUsage(usage x509.KeyUsage) CertOption
WithKeyUsage 设置证书的密钥用途 (Key Usage)。
func WithLocality ¶
func WithLocality(locality string) CertOption
func WithOrganization ¶
func WithOrganization(org string) CertOption
WithOrganization 设置证书的组织 (Organization)。
func WithOrganizationalUnit ¶
func WithOrganizationalUnit(ou string) CertOption
func WithPrivateKey ¶
func WithPrivateKey(key crypto.Signer) CertOption
WithPrivateKey 使用一个已有的私钥来生成证书请求,而不是自动创建新私钥。 私钥必须实现 crypto.Signer 接口。
func WithPrivateKeyFromBytes ¶
func WithPrivateKeyFromBytes(key []byte) CertOption
func WithPrivateKeyFromFile ¶
func WithPrivateKeyFromFile(path string) CertOption
func WithProvince ¶
func WithProvince(province string) CertOption
func WithValidity ¶
func WithValidity(duration time.Duration) CertOption
WithValidity 设置证书的有效期(从现在开始,持续时间为 duration)。
type HandshakeClientHello ¶
type HandshakeClientHello struct {
Random []byte
Session []byte
CipherSuite []byte
CompressionMethods []byte
ExtensionsRaw []byte
Extensions []*HandshakeClientHelloExt
// contains filtered or unexported fields
}
func ParseClientHello ¶
func ParseClientHello(data []byte) (*HandshakeClientHello, error)
ParseClientHello parses a ClientHello message from the given data. It returns the parsed message and the number of bytes consumed.
func (*HandshakeClientHello) ALPN ¶
func (h *HandshakeClientHello) ALPN() []string
func (*HandshakeClientHello) MaybeHttp ¶
func (h *HandshakeClientHello) MaybeHttp() bool
func (*HandshakeClientHello) SNI ¶
func (h *HandshakeClientHello) SNI() string
type HandshakeClientHelloExt ¶
func (*HandshakeClientHelloExt) IsALPN ¶
func (h *HandshakeClientHelloExt) IsALPN() ([]string, bool)
func (*HandshakeClientHelloExt) IsSNI ¶
func (h *HandshakeClientHelloExt) IsSNI() (string, bool)
type SelfSignConfig ¶
type SelfSignConfigOpt ¶
type SelfSignConfigOpt func(*SelfSignConfig)
func WithSelfSign_EnableAuth ¶
func WithSelfSign_EnableAuth(b bool) SelfSignConfigOpt
func WithSelfSign_NotAfter ¶
func WithSelfSign_NotAfter(t time.Time) SelfSignConfigOpt
func WithSelfSign_NotBefore ¶
func WithSelfSign_NotBefore(t time.Time) SelfSignConfigOpt
func WithSelfSign_Organization ¶ added in v1.2.3
func WithSelfSign_Organization(s string) SelfSignConfigOpt
func WithSelfSign_PrivateKey ¶
func WithSelfSign_PrivateKey(p *rsa.PrivateKey) SelfSignConfigOpt
func WithSelfSign_SignTo ¶
func WithSelfSign_SignTo(s ...string) SelfSignConfigOpt