...

Source file src/github.com/letsencrypt/boulder/test/ocsp/checkocsp/checkocsp.go

Documentation: github.com/letsencrypt/boulder/test/ocsp/checkocsp

     1  package main
     2  
     3  import (
     4  	"encoding/hex"
     5  	"flag"
     6  	"fmt"
     7  	"log"
     8  	"math/big"
     9  	"os"
    10  	"strings"
    11  
    12  	"github.com/letsencrypt/boulder/test/ocsp/helper"
    13  )
    14  
    15  func main() {
    16  	flag.Usage = func() {
    17  		fmt.Fprintf(os.Stderr, `
    18  checkocsp [OPTION]... FILE [FILE]...
    19  
    20  OCSP-checking tool. Provide a list of filenames for certificates in PEM format,
    21  and this tool will check OCSP for each certificate based on its AIA field.
    22  It will return an error if the OCSP server fails to respond for any request,
    23  if any response is invalid or has a bad signature, or if any response is too
    24  stale.
    25  
    26  `)
    27  		flag.PrintDefaults()
    28  	}
    29  	helper.RegisterFlags()
    30  	serials := flag.Bool("serials", false, "Parameters are hex-encoded serial numbers instead of filenames. Requires --issuer-file and --url.")
    31  	flag.Parse()
    32  	var errors bool
    33  	if len(flag.Args()) == 0 {
    34  		flag.Usage()
    35  		os.Exit(0)
    36  	}
    37  	config, err := helper.ConfigFromFlags()
    38  	if err != nil {
    39  		log.Fatal(err)
    40  	}
    41  	for _, a := range flag.Args() {
    42  		var err error
    43  		var bytes []byte
    44  		if *serials {
    45  			bytes, err = hex.DecodeString(strings.Replace(a, ":", "", -1))
    46  			if err != nil {
    47  				log.Printf("error for %s: %s\n", a, err)
    48  			}
    49  			serialNumber := big.NewInt(0).SetBytes(bytes)
    50  			_, err = helper.ReqSerial(serialNumber, config)
    51  
    52  		} else {
    53  			_, err = helper.ReqFile(a, config)
    54  		}
    55  		if err != nil {
    56  			log.Printf("error for %s: %s\n", a, err)
    57  			errors = true
    58  		}
    59  	}
    60  	if errors {
    61  		os.Exit(1)
    62  	}
    63  }
    64  

View as plain text