# ConnectionRequest Digest ACS - curl not the same

**URL:** <https://forum.genieacs.com/t/connectionrequest-digest-acs-curl-not-the-same/1063>\
**Category:** Uncategorized\
**Created:** [September 17, 2020, 10:53am UTC](https://forum.genieacs.com/t/connectionrequest-digest-acs-curl-not-the-same/1063 "2020-09-17T10:53:12Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![sebastien.crettaz](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@sebastien.crettaz](https://forum.genieacs.com/u/sebastien.crettaz)\
**Post date:** [September 17, 2020, 10:53am UTC](https://forum.genieacs.com/t/connectionrequest-digest-acs-curl-not-the-same/1063/1 "2020-09-17T10:53:12Z")

</div>

Hello,

I try to make a connection request from the GenieACS but I always get the “Incorrect connection request credentials” message.

I read the other thread about this problem but my problem is not the same.

If I made a call with curl from the same machine, it triggers the connection request :  
curl -i -u USERNAME:PASSWORD http://MY\_CPE\_IP:7547/cpe --digest

Answer :  
HTTP/1.1 401 Unauthorized  
Server: YAPS  
WWW-Authenticate: Digest realm=“YapsieWorld”, qop=“auth”, nonce=“3d8ceffbe336ca61b1f983ae8325f8fc”, opaque=“e7c334cb94a7595234eaf7995785f445”  
Content-Length: 0  
Connection: close

HTTP/1.1 200 OK  
Server: YAPS  
Content-Length: 0  
Connection: close

And I can see in the geniacs-cwmp that the connection request has been triggered immediatly.

I used wireshark to capture the difference between the curl query and the GenieACS one, the only difference I see is the cnonce with curl is much bigger :

GenieACS :  
Digest username=“USERNAME”,realm=“YapsieWorld”,nonce=“32857f8d6076974084b2c9bb23c0655f”,uri="/cpe",qop=auth,nc=00000001,cnonce=“ **690cb04b5a5de2e7** ”,response=“cd5988750e35ab5f6031b5b0b833f633”,opaque=“1d83896d386c34d863a8d888cbdb9338”

Curl :  
Digest username=“USERNAME”,realm=“YapsieWorld”,nonce=“0384f9417161ce3c5c826b1c15d0a751”,uri="/cpe",qop=auth,nc=00000001,cnonce=“ **MGM1N2VjMjE3M2ZhM2FiN2FlZTE4NmY2ZjE1NzNjYmE** =”,response=“4e0293b12cd04a63501d728ede5beefa”,opaque=“d428476e9c92879e4cccc04e096b96ea”

Is there a config to set to solve this issue in GenieACS ?

Thank you and have a nice day !

---

<div class="post-metadata">

**Author:** ![zaidka](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/zaidka/32/9_2.png) [@zaidka](https://forum.genieacs.com/u/zaidka)\
**Post date:** [September 18, 2020, 1:26am UTC](https://forum.genieacs.com/t/connectionrequest-digest-acs-curl-not-the-same/1063/2 "2020-09-18T01:26:45Z")

</div>

There’s no config option for the length of the cnonce value. But you change it in the code in auth.ts line 146.

---

<div class="post-metadata">

**Author:** ![sebastien.crettaz](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@sebastien.crettaz](https://forum.genieacs.com/u/sebastien.crettaz)\
**Post date:** [September 18, 2020, 5:20am UTC](https://forum.genieacs.com/t/connectionrequest-digest-acs-curl-not-the-same/1063/3 "2020-09-18T05:20:57Z")

</div>

Thanks for your reply.

The only problem is that I installed GenieACS not from source, but from npm install (as described in the documentation), so I don’t really know where the files are stored. I tried to find them in the /usr/local/lib/node\_modules/genieacs/ folder without success.

Can you tell me if it is possible to modify the code with a npm install or it’s only from source ?

Thank you and have a nice day !

---

<div class="post-metadata">

**Author:** ![sebastien.crettaz](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@sebastien.crettaz](https://forum.genieacs.com/u/sebastien.crettaz)\
**Post date:** [September 21, 2020, 10:50am UTC](https://forum.genieacs.com/t/connectionrequest-digest-acs-curl-not-the-same/1063/4 "2020-09-21T10:50:34Z")

</div>

Hello,

I found the problem : the issue comes from the encoding of cnonce in the auth.ts file.

I changed this line :

```
 const cnonce = randomBytes(8).toString("hex");

```

By this one :

```
 const cnonce = randomBytes(8).toString("base64");

```

And now it works.

I found in the RFC 2069 that it is recommended to encode the nonce in base64. I think that the CPE I’m using is using the base64 encoding :

```
 nonce
 A server-specified data string which may be uniquely generated each
 time a 401 response is made. It is recommended that this string be
 base64 or hexadecimal data. Specifically, since the string is
 passed in the header lines as a quoted string, the double-quote
 character is not allowed.

```

I don’t know if there is a way to fix this issue in a future release of GenieACS !

Thank you for your help !

---

<div class="post-metadata">

**Author:** ![zaidka](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/zaidka/32/9_2.png) [@zaidka](https://forum.genieacs.com/u/zaidka)\
**Post date:** [September 21, 2020, 5:37pm UTC](https://forum.genieacs.com/t/connectionrequest-digest-acs-curl-not-the-same/1063/5 "2020-09-21T17:37:00Z")

</div>

The cnonce value is just a string that’s opaque to the server so I don’t see it’s attempting to parse and read it. This is definitely an issue that should be raised to the device manufacturer.

---

<div class="post-metadata">

**Author:** ![saschap](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/saschap/32/72_2.png) [@saschap](https://forum.genieacs.com/u/saschap)\
**Post date:** [October 15, 2020, 4:05pm UTC](https://forum.genieacs.com/t/connectionrequest-digest-acs-curl-not-the-same/1063/6 "2020-10-15T16:05:24Z")

</div>

I have the same problem. With GenieACS 1.2.2 I receive “Incorrect connection request credentials”, and with the same credentials with curl ( curl -i -u username:password [http://1x.x.x.x:7547/cpe](http://1x.x.x.x:7547/cpe) --digest ) works…  
I also installed genieacs via npm, how can I recompile it by putting the change in auth.ts file?

---

<div class="post-metadata">

**Author:** ![sebastien.crettaz](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@sebastien.crettaz](https://forum.genieacs.com/u/sebastien.crettaz)\
**Post date:** [November 2, 2020, 6:36am UTC](https://forum.genieacs.com/t/connectionrequest-digest-acs-curl-not-the-same/1063/7 "2020-11-02T06:36:45Z")

</div>

> [@saschap](#):
>
> pile it by putting the change in auth.ts file?

Hello,

To modify the code, you must clone the github repository and modify from there. You cannot modify the compiled versions…

---

<div class="post-metadata">

**Author:** ![sebastien.crettaz](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@sebastien.crettaz](https://forum.genieacs.com/u/sebastien.crettaz)\
**Post date:** [November 6, 2020, 1:46pm UTC](https://forum.genieacs.com/t/connectionrequest-digest-acs-curl-not-the-same/1063/8 "2020-11-06T13:46:35Z")

</div>

Hello again,

I finally found why there is a problem with the authentication with my CPE.

The header HTTP “Authorization” contains all values for authentication Digest and they are correct. But the problem is there is no space between thoses values and the CPE deny the authentication.

To allow this, I modified the file `lib/auth.ts` at line 169 by adding a space between all parameters :

```auto
   let authString = `Digest username="${username}"`;
   authString += `, realm="${authHeader.realm}"`;
   authString += `, nonce="${authHeader.nonce}"`;
   authString += `, uri="${uri}"`;
   if (authHeader.algorithm) authString += `, algorithm=${authHeader.algorithm}`;
   if (qop) authString += `, qop=${qop}, nc=${nc}, cnonce="${cnonce}"`;
   authString += `, response="${hash}"`;
   if (authHeader.opaque) authString += `, opaque="${authHeader.opaque}"`;

```

And now it works !

I don’t know if this should be the standard in the HTTP “Authorization” header but I cannot try this on another modem…

Hope it helps !

---

<div class="post-metadata">

**Author:** ![zaidka](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/zaidka/32/9_2.png) [@zaidka](https://forum.genieacs.com/u/zaidka)\
**Post date:** [November 11, 2020, 6:55am UTC](https://forum.genieacs.com/t/connectionrequest-digest-acs-curl-not-the-same/1063/9 "2020-11-11T06:55:04Z")

</div>

> [@sebastien.crettaz](#):
>
> The header HTTP “Authorization” contains all values for authentication Digest and they are correct. But the problem is there is no space between thoses values and the CPE deny the authentication.

In your comment from Sep 21 you said changing to base64 fixed the issue. Is this for a different device?
