LinuxQuestions.org
Review your favorite Linux distribution.
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, 03: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, 06:27 AM   #2
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 1994Reputation: 1994Reputation: 1994Reputation: 1994Reputation: 1994Reputation: 1994Reputation: 1994Reputation: 1994Reputation: 1994Reputation: 1994Reputation: 1994
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 06:29 AM.
 
Old 07-20-2015, 08: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 08:11 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 04:15 PM
Error: Can't read cert file /etc/pki/tls/certs/cert.pem in Twiki jsaravana87 Linux - Server 1 09-09-2011 07:01 PM
Qmail ssl cert eltonmou Linux - Software 0 08-18-2004 07:48 AM
Webmin SSL Cert hakcenter Linux - Security 4 10-22-2003 05:21 PM

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

All times are GMT -5. The time now is 01:31 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