1
0

reflection work so far...

This commit is contained in:
brent saner
2025-01-25 16:11:19 -05:00
parent bf887ce948
commit 1471dc29ed
31 changed files with 2240 additions and 150 deletions

View File

@@ -57,6 +57,7 @@ func (t *TlsFlat) ToTlsConfig() (tlsConf *tls.Config, err error) {
var curves []tls.CurveID
var minVer uint16
var maxVer uint16
var concatCAs []*x509.Certificate
var buf *bytes.Buffer = new(bytes.Buffer)
var srvNm string = t.SniName
@@ -107,10 +108,15 @@ func (t *TlsFlat) ToTlsConfig() (tlsConf *tls.Config, err error) {
if b, err = os.ReadFile(c.CertFile); err != nil {
return
}
if parsedTlsCerts, err = ParseLeafCert(b, privKeys, intermediateCAs...); err != nil {
if parsedTlsCerts, concatCAs, err = ParseLeafCert(b, privKeys, intermediateCAs...); err != nil {
return
}
tlsCerts = append(tlsCerts, parsedTlsCerts...)
if concatCAs != nil {
for _, ca := range concatCAs {
rootCAs.AddCert(ca)
}
}
}
}
@@ -163,49 +169,49 @@ func (t *TlsFlat) ToTlsUri() (tlsUri *TlsUri, err error) {
// CA cert(s).
if t.CaFiles != nil {
for _, c := range t.CaFiles {
u.Query().Add(TlsUriParamCa, c)
u.Query().Add(ParamCa, c)
}
}
// Keys and Certs.
if t.Certs != nil {
for _, c := range t.Certs {
u.Query().Add(TlsUriParamCert, c.CertFile)
u.Query().Add(ParamCert, c.CertFile)
if c.KeyFile != nil {
u.Query().Add(TlsUriParamKey, *c.KeyFile)
u.Query().Add(ParamKey, *c.KeyFile)
}
}
}
// Enforce the SNI hostname.
u.Query().Add(TlsUriParamSni, t.SniName)
u.Query().Add(ParamSni, t.SniName)
// Disable Verification.
if t.SkipVerify {
u.Query().Add(TlsUriParamNoVerify, "1")
u.Query().Add(ParamNoVerify, "1")
}
// Ciphers.
if t.CipherSuites != nil {
for _, c := range t.CipherSuites {
u.Query().Add(TlsUriParamCipher, c)
u.Query().Add(ParamCipher, c)
}
}
// Minimum TLS Protocol Version.
if t.MinTlsProtocol != nil {
u.Query().Add(TlsUriParamMinTls, *t.MinTlsProtocol)
u.Query().Add(ParamMinTls, *t.MinTlsProtocol)
}
// Maximum TLS Protocol Version.
if t.MaxTlsProtocol != nil {
u.Query().Add(TlsUriParamMaxTls, *t.MaxTlsProtocol)
u.Query().Add(ParamMaxTls, *t.MaxTlsProtocol)
}
// Curves.
if t.Curves != nil {
for _, c := range t.Curves {
u.Query().Add(TlsUriParamCurve, c)
u.Query().Add(ParamCurve, c)
}
}