LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   concat server SSL cert and chain cert (https://www.linuxquestions.org/questions/linux-newbie-8/concat-server-ssl-cert-and-chain-cert-4175548402/)

LYC 07-20-2015 03:22 AM

concat server SSL cert and chain cert
 
Hi,

I have to concat the SSL server cert and chain cert into 1 file. After the concatenation, the content of the file is as follows:

-----BEGIN CERTIFICATE-----
:
-----END CERTIFICATE----------BEGIN CERTIFICATE-----
:
-----END CERTIFICATE-----

Is there any command or work around so that the output is as follows?

-----BEGIN CERTIFICATE-----
:
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
:
-----END CERTIFICATE-----



Thanks in advance

berndbausch 07-20-2015 06:27 AM

It's a text file. Just use vim or so to add the newline.

Or in a script:
Code:

cp cert1 newcert
echo >> newcert
cat cert2 >> newcert

I will leave it up to more knowledgeable LQers to find more elegant ways or oneliners, but this should work.

Habitual 07-20-2015 08:08 AM

the Accepted format is
Code:

-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----

Exactly 5 hyphens (or dashes) with no whitespace.
so, adjust below
"-----END CERTIFICATE-----<cr>-----BEGIN CERTIFICATE-----"
to match accepted format.

I don't believe whitespace matters in between each stanza.
So, what berndbausch suggests is accurate,
but
Code:

cat file1 file2 > newfile
works also ;)


All times are GMT -5. The time now is 07:17 AM.