# WSSE Headers in Net::HTTP

**URL:** <https://www.ruby-forum.com/t/wsse-headers-in-net-http/111117>\
**Category:** Ruby\
**Created:** [August 2, 2007, 8:49pm UTC](https://www.ruby-forum.com/t/wsse-headers-in-net-http/111117 "2007-08-02T20:49:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![michaelb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b19c9b/32.png) [@michaelb](https://www.ruby-forum.com/u/michaelb)\
**Post date:** [August 2, 2007, 8:49pm UTC](https://www.ruby-forum.com/t/wsse-headers-in-net-http/111117/1 "2007-08-02T20:49:29Z")

</div>

Hello all! I am creating an API library for Pownce in Ruby. It’s hard  
because there is no documentation whatsoever, only the hard work done by  
those working on Python and ColdFusion versions. It is a pretty long  
file, so I’ve put it up on pastie ([Parked at Loopia](http://pastie.caboo.se/84428)). The  
server check and  
login are working great and I’m sucessfully getting a token etc., but my  
problem comes starting with view\_notes. The API must create a WSSE token  
to be sent along under the name ‘auth’. I am creating my WSSE header in  
generate\_wsse, and from all I can see it looks right. But, instead of my  
response’s body being the notes, it’s the following error with a 401  
error:

```auto
Unable to parse WSSE header: expected string or buffer
```

Now, I don’t know if this means that it’s unable to parse the header  
because it didn’t get sent, or it’s invalid, or whatever else there may  
be. And so I appeal to you Ruby-ists, hoping that someone else has had  
this issue!

Thanks,  
Michael B.

---

<div class="post-metadata">

**Author:** ![michaelb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b19c9b/32.png) [@michaelb](https://www.ruby-forum.com/u/michaelb)\
**Post date:** [August 3, 2007, 10:52am UTC](https://www.ruby-forum.com/t/wsse-headers-in-net-http/111117/2 "2007-08-03T10:52:28Z")

</div>

An update on the issue - @connection.post takes three paramaters, with  
the second being data, and the third (optional) being headers, which  
explains this issue, at least for now. The current issue is that I now  
get an EOF error, which is understandable because the header being sent  
looks something like:

UsernameToken Username=“michaelboutros”,  
PasswordDigest="4/RlcNgcZyF0y/jDyEUxjSYCcJk=  
", Nonce=“38c7c9d3ef02d856d208d9da0fcf701b”,  
Created=“2007-08-03T03:38:27Z”

The exact error:

EOFError: end of file reached

method sysread in protocol.rb at line 133  
method rbuf\_fill in protocol.rb at line 133  
method timeout in timeout.rb at line 56  
method timeout in timeout.rb at line 76  
method rbuf\_fill in protocol.rb at line 132  
method readuntil in protocol.rb at line 116  
method readline in protocol.rb at line 126  
method read\_status\_line in http.rb at line 2017  
method read\_new in http.rb at line 2006  
method request in http.rb at line 1047  
method view\_notes in pownce\_clean.rb at line 61  
at top level in pownce\_clean.rb at line 69

Wow. As you can see, the PasswordDigest attribute in the WSSE header has  
a newline at the end of it. Adding .chomp! to the password digest  
eliminates the EOF error, but then I’m back to my “unable to parse  
error.”

My head is soon to explode, that’s for sure.
