client.go 581 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package main
  2. import (
  3. "fmt"
  4. "io/ioutil"
  5. "os"
  6. "time"
  7. "github.com/smallstep/certificates/ca"
  8. )
  9. func main() {
  10. if len(os.Args) != 2 {
  11. fmt.Fprintf(os.Stderr, "Usage: %s <token>\n", os.Args[0])
  12. os.Exit(1)
  13. }
  14. token := os.Args[1]
  15. client, err := ca.BootstrapClient(token)
  16. if err != nil {
  17. panic(err)
  18. }
  19. for {
  20. resp, err := client.Get("https://localhost:8443")
  21. if err != nil {
  22. panic(err)
  23. }
  24. b, err := ioutil.ReadAll(resp.Body)
  25. resp.Body.Close()
  26. if err != nil {
  27. panic(err)
  28. }
  29. fmt.Printf("Server responded: %s\n", b)
  30. time.Sleep(1 * time.Second)
  31. }
  32. }