File Coverage

blib/lib/Config/Apple/Profile/Payload/Certificate/PKCS12.pm
Criterion Covered Total %
statement 24 24 100.0
branch n/a
condition n/a
subroutine 8 8 100.0
pod n/a
total 32 32 100.0


line stmt bran cond sub pod time code
1             # This is the code for Config::Apple::Profile::Payload::Certificate::PKCS12.
2             # For Copyright, please see the bottom of the file.
3              
4             package Config::Apple::Profile::Payload::Certificate::PKCS12;
5              
6 1     1   1345 use 5.14.4;
  1         4  
  1         44  
7 1     1   7 use strict;
  1         18  
  1         38  
8 1     1   6 use warnings FATAL => 'all';
  1         4  
  1         42  
9 1     1   6 use base qw(Config::Apple::Profile::Payload::Certificate);
  1         3  
  1         119  
10              
11             our $VERSION = '0.55';
12              
13 1     1   6 use Readonly;
  1         2  
  1         59  
14 1     1   6 use Config::Apple::Profile::Targets qw(:all);
  1         3  
  1         151  
15 1     1   7 use Config::Apple::Profile::Payload::Certificate;
  1         2  
  1         36  
16 1     1   6 use Config::Apple::Profile::Payload::Types qw($ProfileNumber $ProfileString);
  1         7  
  1         264  
17              
18              
19             =encoding utf8
20              
21             =head1 NAME
22              
23             Config::Apple::Profile::Payload::Certificate::PKCS12 - Bundle containing
24             one certificate and its matching private key.
25              
26             =head1 SYNOPSIS
27              
28             use Config::Apple::Profile;
29             use Config::Apple::Profile::Payload::Certificate::PKCS12;
30            
31             my $cert = new Config::Apple::Profile::Payload::Certificate::PKCS12;
32             $cert->payload->{PayloadIdentifier} = 'local.acme.key.user10';
33             $cert->payload->{PayloadDisplayName} = 'Private key & cert';
34             $cert->payload->{PayloadDescription} = 'The private key and certificate for employee #10';
35             $cert->payload->{PayloadOrganization} = 'Acme, Inc.';
36             $cert->payload->{PayloadCertificateFileName} = 'user10.p12';
37             $cert->payload->{Password} = 'Monkey123'; # DON'T DO THIS IN REAL LIFE!!!
38             $cert->payload->{PayloadContent} = '.................'; # Binary data here
39            
40             my $profile = new Config::Apple::Profile;
41             push @{$profile->content}, $cert;
42            
43             print $profile->export;
44            
45            
46             =head1 DESCRIPTION
47              
48             This class implements the PKCS12 type of Certificate payload.
49              
50             This payload contains a single certificate, and the certificate's private key,
51             in a PKCS#12 container. The container is encrypted with a password.
52              
53             This payload is used to hold B certificate. If you have any
54             intermediate certificates, you will need to use a second Certificate payload
55             (either a PEM or a PKCS1) to hold each intermediate certificate.
56              
57              
58             =head1 PAYLOAD KEYS
59              
60             All of the payload keys defined in
61             L are used by this
62             payload.
63              
64             This payload has the following additional keys:
65              
66             =head2 C
67              
68             This is the password needed to decrypt the PKCS#12 file. If no password is
69             provided, the user will be prompted to enter the password when installing the
70             profile.
71              
72             =head2 C
73              
74             This is fixed to the string C.
75              
76             =head2 C
77              
78             This is fixed to the value C<1>.
79              
80             =cut
81              
82             Readonly our %payloadKeys => (
83             # Bring in the certificate keys...
84             %Config::Apple::Profile::Payload::Certificate::payloadKeys,
85            
86             # ... and define our own!
87             'Password' => {
88             type => $ProfileString,
89             description => 'The password used to decrypt the file.',
90             targets => {
91             $TargetIOS => '5.0',
92             $TargetMACOSX => '10.7',
93             },
94             optional => 1,
95             private => 1,
96             },
97            
98             # Since we can't go any deeper, define the type and version!
99             'PayloadType' => {
100             type => $ProfileString,
101             targets => {
102             $TargetIOS => '5.0',
103             $TargetMACOSX => '10.7',
104             },
105             value => 'com.apple.security.pkcs12',
106             },
107             'PayloadVersion' => {
108             type => $ProfileNumber,
109             targets => {
110             $TargetIOS => '5.0',
111             $TargetMACOSX => '10.7',
112             },
113             value => 1,
114             },
115             ); # End of %payloadKeys
116              
117              
118              
119             =head1 ACKNOWLEDGEMENTS
120              
121             Refer to L for acknowledgements.
122              
123             =head1 AUTHOR
124              
125             A. Karl Kornel, C<< >>
126              
127             =head1 COPYRIGHT AND LICENSE
128              
129             Copyright © 2014 A. Karl Kornel.
130              
131             This program is free software; you can redistribute it and/or modify it
132             under the terms of either: the GNU General Public License as published
133             by the Free Software Foundation; or the Artistic License.
134              
135             See L for more information.
136              
137             =cut
138              
139             1;