base64Decode not working to decode CSR

midjoule
Kilo Sage

Hello,

I'm trying to decode a CSR (e.g. https://www.digicert.com/order/sample-csr.php) thanks to the GlideStringUtil.base64Decode function, but the result is not the one expected.

Here is the background script I'm executing, based on a record where I put the CSR sample:

var gr = new GlideRecord('sn_disco_certmgmt_certificate_task');
gr.get('00d208fc871381507f9362c73cbb35ea')
gs.print(GlideStringUtil.base64Decode(gr.csr)) ;

But the output of the function is not readable (see below)

Could you please tell me what I'm doing wrong or if I should perform this activity differently ?

Best regards,
Julien

9 REPLIES 9

Simon Christens
Kilo Sage

Try changing the decode part to

gs.print(GlideStringUtil.base64Decode(gr.getValue(csr))) ;

also there is not attachments shown so its hard to determine whats going on

Hi Simon,

Thanks for your quick feedback.

I tried with gr.getValue, but the result is the same. 

The attachment (output) is in fact embedded into my question.

And here is my record, where the CSR is retrieved from:

find_real_file.png 

Try copying the text directly into the base64Decode('string')

If it still doesnt make sense then you can cross check with an external base64 decoder as well but to me it seems like its not a valid base64 encoded string then

Also you can check out

https://community.servicenow.com/community?id=community_question&sys_id=4a5207eddb98dbc01dcaf3231f96...

Hi @Simon Christensen ,

Thanks for sharing the other post. I did not see it yet, but I've already implemented this solution (going through the mid server). This takes 5-6 secs to execute. That's why I wanted to run a more elegant solution with these base64...code functions.

But according to the replies to this post, there is apparently no other way to decode CSR.

Best regards