public inbox for development@lists.ipfire.org
 help / color / mirror / Atom feed
From: Michael Tremer <michael.tremer@ipfire.org>
To: development@lists.ipfire.org
Subject: [PATCH 16/16] IPsec: Add CA certificate in Apple profile
Date: Thu, 28 May 2020 17:58:50 +0000	[thread overview]
Message-ID: <20200528175850.12638-17-michael.tremer@ipfire.org> (raw)
In-Reply-To: <20200528175850.12638-1-michael.tremer@ipfire.org>

[-- Attachment #1: Type: text/plain, Size: 1760 bytes --]

Signed-off-by: Michael Tremer <michael.tremer(a)ipfire.org>
---
 html/cgi-bin/vpnmain.cgi | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/html/cgi-bin/vpnmain.cgi b/html/cgi-bin/vpnmain.cgi
index bcbe6227e..fa97ed531 100644
--- a/html/cgi-bin/vpnmain.cgi
+++ b/html/cgi-bin/vpnmain.cgi
@@ -1246,13 +1246,23 @@ END
 	my $uuid1 = $uuid->create_str();
 	my $uuid2 = $uuid->create_str();
 
+	my $ca = "";
+	my $ca_uuid = $uuid->create_str();
+
 	my $cert = "";
 	my $cert_uuid = $uuid->create_str();
 
-	# Read and encode certificate
+	# Read and encode the CA & certificate
 	if ($confighash{$key}[4] eq "cert") {
+		my $ca_path = "${General::swroot}/ca/cacert.pem";
 		my $cert_path = "${General::swroot}/certs/$confighash{$key}[1].p12";
 
+		# Read the CA and encode it into Base64
+		open(CA, "<${ca_path}");
+		local($/) = undef; # slurp
+		$ca = MIME::Base64::encode_base64(<CA>);
+		close(CA);
+
 		# Read certificate and encode it into Base64
 		open(CERT, "<${cert_path}");
 		local($/) = undef; # slurp
@@ -1465,6 +1475,25 @@ END
 
 		print "				</data>\n";
 		print "			</dict>\n";
+
+		print "			<dict>\n";
+		print "				<key>PayloadIdentifier</key>\n";
+		print "				<string>org.example.ca</string>\n";
+		print "				<key>PayloadUUID</key>\n";
+		print "				<string>${ca_uuid}</string>\n";
+		print "				<key>PayloadType</key>\n";
+		print "				<string>com.apple.security.root</string>\n";
+		print "				<key>PayloadVersion</key>\n";
+		print "				<integer>1</integer>\n";
+		print "				<key>PayloadContent</key>\n";
+		print "				<data>\n";
+
+		foreach (split /\n/,${ca}) {
+			print "					$_\n";
+		}
+
+		print "				</data>\n";
+		print "			</dict>\n";
 	}
 
 	print "		</array>\n";
-- 
2.20.1


  parent reply	other threads:[~2020-05-28 17:58 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-28 17:58 Easy IPsec connections for macOS & iOS Michael Tremer
2020-05-28 17:58 ` [PATCH 01/16] IPsec: Use sane defaults for certificate lifetimes Michael Tremer
2020-05-28 17:58 ` [PATCH 02/16] IPsec: Add prototype to export Apple Configuration profiles Michael Tremer
2020-05-28 17:58 ` [PATCH 03/16] perl: Package Data::UUID Michael Tremer
2020-05-28 17:58 ` [PATCH 04/16] vpnmain.cgi: Generate random UUIDs Michael Tremer
2020-05-28 17:58 ` [PATCH 05/16] vpnmain.cgi: Add field for roadwarrior endpoint Michael Tremer
2020-05-28 17:58 ` [PATCH 06/16] vpnmain.cgi: Fix indentation on Apple profiles Michael Tremer
2020-05-28 17:58 ` [PATCH 07/16] IPsec: Apple: Enable PFS on client when enabled Michael Tremer
2020-05-28 17:58 ` [PATCH 08/16] IPsec: Apple: Add desired cipher suites to profiles Michael Tremer
2020-05-28 17:58 ` [PATCH 09/16] IPsec: Apple: Stop prompting for credentials Michael Tremer
2020-05-28 17:58 ` [PATCH 10/16] IPsec: Allow sending DNS server addresses to RW clients Michael Tremer
2020-05-28 17:58 ` [PATCH 11/16] IPsec: Always send our host certificate to all " Michael Tremer
2020-05-28 17:58 ` [PATCH 12/16] IPsec: Set display name for VPN connections Michael Tremer
2020-05-28 17:58 ` [PATCH 13/16] IPsec: Ensure that iOS VPNs are always connected Michael Tremer
2020-05-28 17:58 ` [PATCH 14/16] IPsec: Strip @ from IDs in Apple profile Michael Tremer
2020-05-28 17:58 ` [PATCH 15/16] Revert "IPsec: Apple: Stop prompting for credentials" Michael Tremer
2020-05-28 17:58 ` Michael Tremer [this message]
2020-05-28 18:30 ` Easy IPsec connections for macOS & iOS Tom Rymes
2020-05-28 18:58   ` Michael Tremer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200528175850.12638-17-michael.tremer@ipfire.org \
    --to=michael.tremer@ipfire.org \
    --cc=development@lists.ipfire.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox