LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-20-2015, 02:22 AM   #1
LYC
Member
 
Registered: Jan 2014
Posts: 109

Rep: Reputation: Disabled
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
 
Old 07-20-2015, 05:27 AM   #2
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
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.

Last edited by berndbausch; 07-20-2015 at 05:29 AM.
 
Old 07-20-2015, 07:08 AM   #3
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
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

Last edited by Habitual; 07-20-2015 at 07:11 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
SSL Cert and Apache ajburch Linux - Server 1 05-13-2014 03:15 PM
Error: Can't read cert file /etc/pki/tls/certs/cert.pem in Twiki jsaravana87 Linux - Server 1 09-09-2011 06:01 PM
Qmail ssl cert eltonmou Linux - Software 0 08-18-2004 06:48 AM
Webmin SSL Cert hakcenter Linux - Security 4 10-22-2003 04:21 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration