| 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 | 3 | ▶ | use 5.10.1; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 3 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 3 | ▶ | use warnings FATAL => 'all'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 3 | ▶ | use base qw(Config::Apple::Profile::Payload::Certificate); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | |||
| 11 | 3 | our $VERSION = '0.87.1'; | |
| 12 | |||
| 13 | 3 | ▶ | use Readonly; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 14 | 3 | ▶ | use Config::Apple::Profile::Targets qw(:all); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 15 | 3 | ▶ | use Config::Apple::Profile::Payload::Certificate; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 16 | 3 | ▶ | use Config::Apple::Profile::Payload::Types qw($ProfileNumber $ProfileString); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 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<only one> 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<Config::Apple::Profile::Payload::Common::Certificate> are used by this | ||
| 62 | payload. | ||
| 63 | |||
| 64 | This payload has the following additional keys: | ||
| 65 | |||
| 66 | =head2 C<Password> | ||
| 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 | B<WARNING:> iOS 7 and 8 seem to have problems with identity certificates that do | ||
| 73 | not have the C<Password> key in the payload. More information, and status, | ||
| 74 | are in L<https://github.com/akkornel/Config-Apple-Profile/issues/7>. | ||
| 75 | |||
| 76 | =head2 C<PayloadType> | ||
| 77 | |||
| 78 | This is fixed to the string C<com.apple.security.pkcs12>. | ||
| 79 | |||
| 80 | =head2 C<PayloadVersion> | ||
| 81 | |||
| 82 | This is fixed to the value C<1>. | ||
| 83 | |||
| 84 | =cut | ||
| 85 | |||
| 86 | 3 | Readonly our %payloadKeys => ( | |
| 87 | # Bring in the certificate keys... | ||
| 88 | %Config::Apple::Profile::Payload::Certificate::payloadKeys, | ||
| 89 | |||
| 90 | # ... and define our own! | ||
| 91 | 'Password' => { | ||
| 92 | type => $ProfileString, | ||
| 93 | description => 'The password used to decrypt the file.', | ||
| 94 | targets => { | ||
| 95 | $TargetIOS => '5.0', | ||
| 96 | $TargetMACOSX => '10.7', | ||
| 97 | }, | ||
| 98 | optional => 1, | ||
| 99 | private => 1, | ||
| 100 | }, | ||
| 101 | |||
| 102 | # Since we can't go any deeper, define the type and version! | ||
| 103 | 'PayloadType' => { | ||
| 104 | type => $ProfileString, | ||
| 105 | targets => { | ||
| 106 | $TargetIOS => '5.0', | ||
| 107 | $TargetMACOSX => '10.7', | ||
| 108 | }, | ||
| 109 | value => 'com.apple.security.pkcs12', | ||
| 110 | }, | ||
| 111 | 'PayloadVersion' => { | ||
| 112 | type => $ProfileNumber, | ||
| 113 | targets => { | ||
| 114 | $TargetIOS => '5.0', | ||
| 115 | $TargetMACOSX => '10.7', | ||
| 116 | }, | ||
| 117 | value => 1, | ||
| 118 | }, | ||
| 119 | ); # End of %payloadKeys | ||
| 120 | |||
| 121 | |||
| 122 | |||
| 123 | =head1 ACKNOWLEDGEMENTS | ||
| 124 | |||
| 125 | Refer to L<Config::Apple::Profile> for acknowledgements. | ||
| 126 | |||
| 127 | =head1 AUTHOR | ||
| 128 | |||
| 129 | A. Karl Kornel, C<< <karl at kornel.us> >> | ||
| 130 | |||
| 131 | =head1 COPYRIGHT AND LICENSE | ||
| 132 | |||
| 133 | Copyright © 2014 A. Karl Kornel. | ||
| 134 | |||
| 135 | This program is free software; you can redistribute it and/or modify it | ||
| 136 | under the terms of either: the GNU General Public License as published | ||
| 137 | by the Free Software Foundation; or the Artistic License. | ||
| 138 | |||
| 139 | See L<http://dev.perl.org/licenses/> for more information. | ||
| 140 | |||
| 141 | =cut | ||
| 142 | |||
| 143 | 3 | 1; | |