-
-
Save mendsley/840ce420b1769b05b4e2a22b12538e8e to your computer and use it in GitHub Desktop.
This file contains 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 ( | |
"context" | |
"crypto/ecdsa" | |
"crypto/elliptic" | |
"crypto/rand" | |
"errors" | |
"log" | |
"net/http" | |
"golang.org/x/crypto/acme" | |
) | |
type MockTransport struct{} | |
func (mt *MockTransport) RoundTrip(r *http.Request) (*http.Response, error) { | |
return nil, errors.New("Not implemented") | |
} | |
func main() { | |
key, err := ecdsa.GenerateKey(elliptic.P521(), rand.Reader) | |
if err != nil { | |
log.Fatal("Failed to generate key: ", err) | |
} | |
cl := &acme.Client{ | |
Key: key, | |
HTTPClient: &http.Client{ | |
Transport: new(MockTransport), | |
}, | |
} | |
_, err = cl.GetReg(context.Background(), "http://example.com/registration") | |
if err == acme.ErrUnsupportedKey { | |
log.Fatal("Should support ES512 signatures") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment