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

Ankur Bawiskar
Tera Patron
Tera Patron

@midjoule 

So you have a field which holds base64encoded data?

you want to decode and do what with that?

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi Ankur,

I want to extract data from it, like this site https://certlogik.com/decoder/ does, and show the attributes of the CSR to the end user who wants to submit it to DigiCert to get it signed. Showing the details will help him confirm it's the right CSR and also I'll be able to check if the encryption key is 4096 and not 2048 for instance.

Again, I don't know if I use the right approach. If not please let me know how I could achieve this.

Best regards,
Julien

 

Hi,

but usually base64 encoding is done for files

Consider if the base64encoded data is for word file; then what will you show to the user

We usually decoded the data and add that content in file

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi @Ankur Bawiskar,

I don't see the point regarding the word file, but if base64...code functions work for Word files, shouldn't they work for CSR ?

Is there really no way decoding a base64 encrypted CSR ?

Best regards,
Julien

Hi,

Not much aware on that

regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader