Skip to content

Commit

Permalink
Tweaks.
Browse files Browse the repository at this point in the history
  • Loading branch information
shuque committed May 31, 2020
1 parent a36b8b9 commit 6976785
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Appname and Servicename methods on the Config structure.
### Example code

Example code that uses this library can be found in example_test.go.
A detailed example program that uses the library can be found at
A detailed diagnostic tool that uses the library can be found at
https://github.com/shuque/gotls

### Documentation
Expand Down
1 change: 0 additions & 1 deletion byname.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ func ConnectByName(hostname string, port int) (*tls.Conn, *Config, error) {
}

for _, ip := range iplist {

config := NewConfig(hostname, ip, port)
config.SetTLSA(tlsa)
conn, err = DialTLS(config)
Expand Down
5 changes: 4 additions & 1 deletion dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,10 @@ func GetTLSA(resolver *Resolver, hostname string, port int) (*TLSAinfo, error) {
}

if response.MsgHdr.Rcode == dns.RcodeNameError {
return nil, fmt.Errorf("%s: Non-existent domain name", qname)
if resolver.Pkixfallback {
return nil, nil
}
return nil, fmt.Errorf("ERROR: %s: Non-exist domain name", hostname)
}

tlsa := new(TLSAinfo)
Expand Down
2 changes: 0 additions & 2 deletions tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@ func verifyChain(certs []*x509.Certificate, config *tls.Config,
if root {
opts.Roots = config.RootCAs
opts.Intermediates = x509.NewCertPool()

for _, cert := range certs[1:] {
opts.Intermediates.AddCert(cert)
}
verifiedChains, err = certs[0].Verify(opts)
} else {
opts.Roots = x509.NewCertPool()

chainlength := len(certs)
last := certs[chainlength-1]
opts.Roots.AddCert(last)
Expand Down
24 changes: 12 additions & 12 deletions tlsa.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@ import (
)

//
// DANE Usage modes
// DANE Certificte Usage modes
//
const (
PkixTA = 0
PkixEE = 1
DaneTA = 2
DaneEE = 3
PkixTA = 0 // Certificate Authority Constraint
PkixEE = 1 // Service Certificate Constraint
DaneTA = 2 // Trust Anchor Assertion
DaneEE = 3 // Domain Issued Certificate
)

//
// TLSArdata - TLSA rdata structure
//
type TLSArdata struct {
Usage uint8
Selector uint8
Mtype uint8
Data string
Checked bool
Ok bool
Message string
Usage uint8 // Certificate Usage
Selector uint8 // Selector: 0: full cert, 1: subject public key
Mtype uint8 // Matching Type: 0 full content, 1: SHA256, 2: SHA512
Data string // Certificate association Data field (hex encoding)
Checked bool // Have we tried to match this TLSA rdata?
Ok bool // Did it match?
Message string // Diagnostic message for matching
}

//
Expand Down

0 comments on commit 6976785

Please sign in to comment.