@@ -15,10 +15,10 @@ import (
1515 "net/url"
1616 "time"
1717
18- "github.com/coreos/go-oidc/jose"
1918 homedir "github.com/mitchellh/go-homedir"
2019 "github.com/pkg/errors"
2120 gossh "golang.org/x/crypto/ssh"
21+ "gopkg.in/square/go-jose.v2/jwt"
2222
2323 "github.com/cloudflare/cloudflared/config"
2424 cfpath "github.com/cloudflare/cloudflared/token"
@@ -87,37 +87,33 @@ func SignCert(token, pubKey string) (string, error) {
8787 return "" , errors .New ("invalid token" )
8888 }
8989
90- jwt , err := jose . ParseJWT (token )
90+ parsedToken , err := jwt . ParseSigned (token )
9191 if err != nil {
9292 return "" , errors .Wrap (err , "failed to parse JWT" )
9393 }
9494
95- claims , err := jwt .Claims ()
95+ claims := jwt.Claims {}
96+ err = parsedToken .UnsafeClaimsWithoutVerification (& claims )
9697 if err != nil {
9798 return "" , errors .Wrap (err , "failed to retrieve JWT claims" )
9899 }
99100
100- issuer , _ , err := claims .StringClaim ("iss" )
101- if err != nil {
102- return "" , errors .Wrap (err , "failed to retrieve JWT iss" )
103- }
104-
105101 buf , err := json .Marshal (& signPayload {
106102 PublicKey : pubKey ,
107103 JWT : token ,
108- Issuer : issuer ,
104+ Issuer : claims . Issuer ,
109105 })
110106 if err != nil {
111107 return "" , errors .Wrap (err , "failed to marshal signPayload" )
112108 }
113109 var res * http.Response
114110 if mockRequest != nil {
115- res , err = mockRequest (issuer + signEndpoint , "application/json" , bytes .NewBuffer (buf ))
111+ res , err = mockRequest (claims . Issuer + signEndpoint , "application/json" , bytes .NewBuffer (buf ))
116112 } else {
117113 client := http.Client {
118114 Timeout : 10 * time .Second ,
119115 }
120- res , err = client .Post (issuer + signEndpoint , "application/json" , bytes .NewBuffer (buf ))
116+ res , err = client .Post (claims . Issuer + signEndpoint , "application/json" , bytes .NewBuffer (buf ))
121117 }
122118
123119 if err != nil {
0 commit comments