cloudflare / cloudflare/cfssl

Unable to invoke the authsign api

Open
#864 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
9.5k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

@kisom @anniephan Following this issue- https://github.com/cloudflare/cfssl/issues/460 , I'm unable to generate a valid authsign request, and keep getting the 'invalid token' response: {"success":false,"result":null,"errors":[{"code":400,"message":"invalid token"}],"messages":[]} .
I attempted to write a java program that creates an authsign request: I used the [auth test config](https://github.com/cloudflare/cfssl/blob/master/config/testdata/valid_config_auth.json) for the cfssl server, and the code:
```
...
private static String key = "0123456789ABCDEF0123456789ABCDEF";

public static String encode(String key, String data) throws Exception {
Mac sha256_HMAC = Mac.getInstance("HmacSHA256");
String keyHex= Hex.encodeHexString(key.getBytes("UTF-8"));

SecretKeySpec secret_key = new SecretKeySpec(keyHex.getBytes(), "HmacSHA256");
// use key
sha256_HMAC.init(secret_key);
// combine with cert signing request
byte[] updatedHmacWithReq = sha256_HMAC.doFinal(data.getBytes("UTF-8"));
// HMAC-SHA256 to base64
return Base64.encodeBase64String(updatedHmacWithReq);
}

public static void main(String [] args) throws Exception {
System.out.println("Token in base 64:");
System.out.println(encode(key, signReq));
System.out.println(Request in base 64:");
System.out.println(Base64.encodeBase64String(signReq.getBytes()));
}
...
```
And then used the printed token and request for authsign request, and got "invalid token" for different signReq requests- the signReq is String loaded from file:
{
"request": "-----BEGIN CERTIFICATE REQUEST----- ... -----END CERTIFICATE REQUEST-----\n",
"profile": "CA"
}

@krish7919 In addition, as mentioned- the [testdata](https://github.com/cloudflare/cfssl/blob/master/auth/testdata/authrequest.json) does not work with the API.

Can someone suggest what is not correct in my authsign request generation? Or reference to an example of generating json for an authsign request?

Thanks!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.