I am attempting to follow this reply and change a few hex bytes in a file by using hexdump, xxd, and sed.
According to that response, after converting the CSR generated with keytool (which happens to be base-64 PEM format) into DER, I should be able to do a straight bytes replacement, replacing 0x13
with 0x0c
.
Here is what I have attempted:
#convert csr pem to der
openssl req -in openfire.csr -outform der -out openfire_csr.der
cat openfire_csr.der | grep -aP '\x13' | md5sum
#e61387f5c1xxxxeb832df102524220d81 - #it has some length
#perform replacement of hex bytes:
sed 's/\x13/\x0c/g' openfire_csr.der
#convert csr der to csr pem:
openssl req -in openfire_csr.der -outform pem -out openfire_utf8.csr
#unable to load X509 request
#3078055660:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:698:Expecting: CERTIFICATE REQUEST
I suspect I'm missing some conversion, but I do not know where.
How do I perform byte replacement using available tools (like sed
, xxd
, and/or hexdump
)?