init
This commit is contained in:
commit
77e40f9d4a
20
LICENSE
Normal file
20
LICENSE
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
MIT License
|
||||||
|
Copyright (c) 2017 Stephen McQuay
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||||
|
of the Software, and to permit persons to whom the Software is furnished to do
|
||||||
|
so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
23
README.md
Normal file
23
README.md
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# certexp
|
||||||
|
|
||||||
|
report certificate expiry for a collection of servers, which yields equivalent
|
||||||
|
information to:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ echo | openssl s_client -connect $hostname:$port 2> /dev/null | openssl x509 -noout -dates | grep notAfter
|
||||||
|
```
|
||||||
|
|
||||||
|
## example usage
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ cat sites.txt
|
||||||
|
apple.com
|
||||||
|
google.com
|
||||||
|
amazon.com
|
||||||
|
imap.gmail.com:993
|
||||||
|
$ cat sites.txt | certexp
|
||||||
|
apple.com 2018-10-31 23:59:59 +0000 UTC
|
||||||
|
google.com 2018-02-13 15:19:00 +0000 UTC
|
||||||
|
amazon.com 2018-09-21 23:59:59 +0000 UTC
|
||||||
|
imap.gmail.com 2018-02-27 09:29:00 +0000 UTC
|
||||||
|
```
|
44
main.go
Normal file
44
main.go
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bufio"
|
||||||
|
"crypto/tls"
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
"net"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
s := bufio.NewScanner(os.Stdin)
|
||||||
|
for s.Scan() {
|
||||||
|
line := s.Text()
|
||||||
|
if line == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
host, port := line, "443"
|
||||||
|
if h, p, err := net.SplitHostPort(line); err == nil {
|
||||||
|
host, port = h, p
|
||||||
|
}
|
||||||
|
|
||||||
|
c, err := tls.Dial("tcp", fmt.Sprintf("%v:%v", host, port), nil)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("dial: %v", err)
|
||||||
|
}
|
||||||
|
if err := c.Handshake(); err != nil {
|
||||||
|
log.Fatalf("handshake: %v", err)
|
||||||
|
}
|
||||||
|
if err := c.Close(); err != nil {
|
||||||
|
log.Fatalf("close: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, chain := range c.ConnectionState().VerifiedChains {
|
||||||
|
for _, cert := range chain {
|
||||||
|
if cert.DNSNames != nil {
|
||||||
|
fmt.Printf("%-24v %v\n", host, cert.NotAfter)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user