-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update components #9
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,19 @@ | ||
# dane | ||
|
||
Go library for DANE TLSA authentication | ||
|
||
### Pre-requisites | ||
## Pre-requisites | ||
|
||
* Go | ||
* Go dns package from https://github.com/miekg/dns | ||
|
||
### Documentation | ||
## Documentation | ||
|
||
Formatted documentation for this module can be found at: | ||
|
||
https://pkg.go.dev/github.com/shuque/dane?tab=doc | ||
|
||
### Description | ||
## Description | ||
|
||
Package dane provides a set of functions to perform DANE authentication | ||
of a TLS server, with fall back to PKIX authentication if no DANE TLSA | ||
|
@@ -74,12 +75,11 @@ will return a working TLS connection handle even if server authentication | |
fails (rather than an error), but will populate the dane.Config's DiagError | ||
member with the appropriate error instead. | ||
|
||
|
||
### Example code | ||
## Example code | ||
|
||
The basic steps in summary form are: | ||
|
||
``` | ||
```go | ||
import ( | ||
... | ||
"github.com/shuque/dane" | ||
|
@@ -94,24 +94,24 @@ tlsa, err := dane.GetTLSA(resolver, hostname, port) | |
iplist, err := dane.GetAddresses(resolver, hostname, true) | ||
|
||
for _, ip := range iplist { | ||
daneconfig := dane.NewConfig(hostname, ip, 443) | ||
daneconfig.SetTLSA(tlsa) | ||
conn, err := dane.DialTLS(daneconfig) | ||
if err != nil { | ||
fmt.Printf("Result: FAILED: %s\n", err.Error()) | ||
continue | ||
} | ||
if daneconfig.Okdane { | ||
fmt.Printf("Result: DANE OK\n") | ||
} else if daneconfig.Okpkix { | ||
fmt.Printf("Result: PKIX OK\n") | ||
} else { | ||
fmt.Printf("Result: FAILED\n") | ||
} | ||
// | ||
// do some stuff with the obtained TLS connection here | ||
// | ||
conn.Close() | ||
daneconfig := dane.NewConfig(hostname, ip, 443) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tabs are not allowed in markdown. |
||
daneconfig.SetTLSA(tlsa) | ||
conn, err := dane.DialTLS(daneconfig) | ||
if err != nil { | ||
fmt.Printf("Result: FAILED: %s\n", err.Error()) | ||
continue | ||
} | ||
if daneconfig.Okdane { | ||
fmt.Printf("Result: DANE OK\n") | ||
} else if daneconfig.Okpkix { | ||
fmt.Printf("Result: PKIX OK\n") | ||
} else { | ||
fmt.Printf("Result: FAILED\n") | ||
} | ||
// | ||
// do some stuff with the obtained TLS connection here | ||
// | ||
conn.Close() | ||
} | ||
``` | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,23 @@ | ||
github.com/miekg/dns v1.1.55 h1:GoQ4hpsj0nFLYe+bWiCToyrBEJXkQfOOIvFGFy0lEgo= | ||
github.com/miekg/dns v1.1.55/go.mod h1:uInx36IzPl7FYnDcMeVWxj9byh7DutNykX4G9Sj60FY= | ||
github.com/miekg/dns v1.1.61 h1:nLxbwF3XxhwVSm8g9Dghm9MHPaUZuqhPiGL+675ZmEs= | ||
github.com/miekg/dns v1.1.61/go.mod h1:mnAarhS3nWaW+NVP2wTkYVIZyHNJ098SJZUki3eykwQ= | ||
golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= | ||
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= | ||
golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8= | ||
golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= | ||
golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= | ||
golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= | ||
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= | ||
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= | ||
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= | ||
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= | ||
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= | ||
golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= | ||
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= | ||
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= | ||
golang.org/x/tools v0.11.0 h1:EMCa6U9S2LtZXLAMoWiR/R8dAQFRqbAitmbJ2UKhoi8= | ||
golang.org/x/tools v0.11.0/go.mod h1:anzJrxPjNtfgiYQYirP2CPGzGLxrH2u2QBhn6Bf3qY8= | ||
golang.org/x/tools v0.23.0 h1:SGsXPZ+2l4JsgaCKkx+FQ9YZ5XEtA1GZYuoDjenLjvg= | ||
golang.org/x/tools v0.23.0/go.mod h1:pnu6ufv6vQkll6szChhK3C3L/ruaIv5eBeztNG8wtsI= |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ package dane | |
|
||
import ( | ||
"fmt" | ||
"io/ioutil" | ||
"io" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ioutil.ReadAll is a deprecated method |
||
"net/http" | ||
"testing" | ||
) | ||
|
@@ -35,7 +35,7 @@ func TestGetHttpClient(t *testing.T) { | |
defer response.Body.Close() | ||
} | ||
|
||
body, err := ioutil.ReadAll(response.Body) | ||
body, err := io.ReadAll(response.Body) | ||
if err != nil { | ||
t.Fatalf("Reading HTTP response body: %s\n", err.Error()) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,7 +47,7 @@ func verifyChain(certs []*x509.Certificate, config *tls.Config, | |
// Config data structure that performs DANE and PKIX authentication of | ||
// the server certificate as appropriate. | ||
func verifyServer(rawCerts [][]byte, | ||
verifiedChains [][]*x509.Certificate, | ||
_ [][]*x509.Certificate, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this parameter is unused |
||
tlsconfig *tls.Config, daneconfig *Config) error { | ||
|
||
var err error | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Markdown linting requires titles not to skip a level.