On 24.02.21 17:46, Iuri de Araujo Sampaio wrote:
Even though, I still have no idea why that happens.

please re-read the following lines of my last answer. What is unclear about  this?
Since it works now, it is clear, that the line-breaks caused you troubles.

The line-breaks are usual for base64 encoders (GNU uuencode, tcllib base64::encode, ...), so ns_base64encode is just compatible with these.

The code in OpenACS, that David has pointed to, has therefore exactly the same problem, when the encoded string starts to contain line breaks. Usually userid+password are not so long as in your case, so this bug was not noticed before.

-gn


On Raj. 13, 1442 AH, at 00:03, Gustaf Neumann <neum...@wu.ac.at <mailto:neum...@wu.ac.at>> wrote:

Dear Iuri,

The problem, you are probably facing is probably that ns_base64encode produces line breaks as required for MIME encoded text strings [1].

% ns_base64encode 
Afrewf564DFSFSF54jgnfhgGDGdfRGRT43:7584fjhfjhf84jkrugrefAFFD9449474
QWZyZXdmNTY0REZTRlNGNTRqZ25maGdHREdkZlJHUlQ0Mzo3NTg0ZmpoZmpo
Zjg0amtydWdyZWZBRkZEOTQ0OTQ3NA==

Converting to and from a string with these linebreaks should be fine for all base64 codecs (you see, colon is not the problem)

% ns_base64decode [ns_base64encode 
Afrewf564DFSFSF54jgnfhgGDGdfRGRT43:7584fjhfjhf84jkrugrefAFFD9449474]
Afrewf564DFSFSF54jgnfhgGDGdfRGRT43:7584fjhfjhf84jkrugrefAFFD9449474
But probably, the header field has problems with linebreaks. Therefore, simply remove the newlines by e.g.
set credentials [join [ns_base64encode 
Afrewf564DFSFSF54jgnfhgGDGdfRGRT43:7584fjhfjhf84jkrugrefAFFD9449474] ""]
set req_headers [ns_set create headers Authorization "Basic $credentials"]

All the best
-g

PS: In order to see, what is sent via and and/or node, use tcpdump and/or wireshark, then you do not have to do any guessing, what is exactly sent by which command in which implementation....

[1] https://unix.stackexchange.com/questions/447191/whats-the-right-way-to-base64-encode-a-binary-file-on-centos-7#:~:text=base64%20inserts%20line%20breaks%20after,Transfer%2DEncoding%20for%20emails).


_______________________________________________
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net <mailto:naviserver-devel@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/naviserver-devel



_______________________________________________
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel

--
Univ.Prof. Dr. Gustaf Neumann
Head of the Institute of Information Systems and New Media
of Vienna University of Economics and Business
Program Director of MSc "Information Systems"

_______________________________________________
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel

Reply via email to