0

i have this CERTIFICATE file enter image description here

-----BEGIN CERTIFICATE REQUEST-----
MIIFIDCCAwgCAQAwIDEeMBwGA1UEAwwVdmF1bHQudmF1bHQtcGVyc28uc3ZjMIIC
IjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA2h1Io+IPgBFYa+L9TFQ3hXDk
dKJFHVBHFx6RaYMDHJe75c/Ozq3zwAwlDlPviTvB96OyuBX9KIBDk5b0QCELYHym
omCSm1GO+Izxgu26aBvrbgycwUml+lXqW8R6reMpEBnaIRgOvPhIsncaR3iQBt8m
yPo/v5ouPCrVGJ5Hehi4ll0vwxI5/ETlJIjnDqBODwWRLvktv4ysHRj/4hyh5Yn0
IalOn9Cxo0w2zVQhFE63n3enz7c=
-----END CERTIFICATE REQUEST-----

i try to remove all the CRLF from the file

like this also tried tr -d "\n" and tr -d "\r" :

cat <<EOF >${TMPDIR}/csr.yaml
apiVersion: certificates.k8s.io/v1beta1
kind: CertificateSigningRequest
metadata:
 name: ${CSR_NAME}
spec:
 groups:
 — system:authenticated
 request: $(cat ${TMPDIR}/server.csr | base64 | sed -e 's/\r//g')
 usages:
 — digital signature
 — key encipherment
 — server auth
EOF

no matter what i do the end result file the part of the CERTIFICATE content is still contains the line break How can i remove it ? enter image description here

user63898
  • 29,839
  • 85
  • 272
  • 514

1 Answers1

0

Try:

cat -v file.csr | tr "^M" "\n" | tr -d "\n"

This will output the file with Windows file endings (-v) before using tr to replace the file endings (^M) with a new line and then delete the new lines (-d)

Raman Sailopal
  • 12,320
  • 2
  • 11
  • 18