base64Decode not working to decode CSR

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2022 11:09 PM
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
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2022 11:29 PM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2022 11:59 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2022 12:15 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2022 09:22 PM
Hi
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