Created
          December 12, 2018 13:19 
        
      - 
      
- 
        Save anisse/41eac87aceef6f6ddbed165b38d4bf80 to your computer and use it in GitHub Desktop. 
    Livecoding Autocert Golang Paris 2018-12-11
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | package main | |
| import ( | |
| "log" | |
| "net/http" | |
| "golang.org/x/crypto/acme/autocert" | |
| ) | |
| func rootHandler(w http.ResponseWriter, r *http.Request) { | |
| w.Write([]byte("Hello, eTF1 et le meetup Golang Paris")) | |
| } | |
| func main() { | |
| m := autocert.Manager{ | |
| Cache: autocert.DirCache("certs"), | |
| Prompt: autocert.AcceptTOS, | |
| Email: "[email protected]", | |
| HostPolicy: autocert.HostWhitelist("meetupgo.pw"), | |
| } | |
| s := &http.Server{ | |
| Addr: ":https", | |
| TLSConfig: m.TLSConfig(), | |
| } | |
| http.HandleFunc("/", rootHandler) | |
| log.Fatal(s.ListenAndServeTLS("", "")) | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment