@@ -64,6 +64,11 @@ Path to the signing certificate
6464
6565Path to the private key for the signing certificate
6666
67+ =item B<encryption_key >
68+
69+ Path to the public key that the IdP should use for encryption. This
70+ is used when generating the metadata.
71+
6772=item B<cacert >
6873
6974Path to the CA certificate for verification
@@ -156,6 +161,7 @@ has 'cert' => (isa => 'Str', is => 'ro', required => 1);
156161has ' key' => (isa => ' Str' , is => ' ro' , required => 1);
157162has ' cacert' => (isa => ' Str' , is => ' rw' , required => 0, predicate => ' has_cacert' );
158163
164+ has ' encryption_key' => (isa => ' Str' , is => ' ro' , required => 0, predicate => ' has_encryption_key' );
159165has ' error_url' => (isa => Uri, is => ' ro' , required => 1, coerce => 1);
160166has ' org_name' => (isa => ' Str' , is => ' ro' , required => 1);
161167has ' org_display_name' => (isa => ' Str' , is => ' ro' , required => 1);
@@ -172,6 +178,7 @@ has 'acs_url_artifact' => (isa => 'Str', is => 'ro', required => 0);
172178
173179has ' _cert_text' => (isa => ' Str' , is => ' ro' , init_arg => undef , builder => ' _build_cert_text' , lazy => 1);
174180
181+ has ' _encryption_key_text' => (isa => ' Str' , is => ' ro' , init_arg => undef , builder => ' _build_encryption_key_text' , lazy => 1);
175182has ' authnreq_signed' => (isa => ' Bool' , is => ' ro' , required => 0, default => 1);
176183has ' want_assertions_signed' => (isa => ' Bool' , is => ' ro' , required => 0, default => 1);
177184
@@ -268,6 +275,15 @@ around BUILDARGS => sub {
268275 return $self -> $orig (%args );
269276};
270277
278+ sub _build_encryption_key_text {
279+ my ($self ) = @_ ;
280+
281+ my $cert = Crypt::OpenSSL::X509-> new_from_file($self -> encryption_key);
282+ my $text = $cert -> as_string;
283+ $text =~ s / -----[^-]*-----// gm ;
284+ return $text ;
285+ }
286+
271287sub _build_cert_text {
272288 my ($self ) = @_ ;
273289
@@ -520,7 +536,9 @@ sub generate_metadata {
520536 protocolSupportEnumeration => URN_PROTOCOL,
521537 },
522538
523- $self -> _generate_key_descriptors($x ),
539+ $self -> _generate_key_descriptors($x , ' signing' ),
540+
541+ $self -> has_encryption_key ? $self -> _generate_key_descriptors($x , ' encryption' ) : (),
524542
525543 $self -> _generate_single_logout_service($x ),
526544
@@ -554,6 +572,7 @@ sub generate_metadata {
554572sub _generate_key_descriptors {
555573 my $self = shift ;
556574 my $x = shift ;
575+ my $use = shift ;
557576
558577 return
559578 if !$self -> authnreq_signed
@@ -562,22 +581,21 @@ sub _generate_key_descriptors {
562581
563582 return $x -> KeyDescriptor(
564583 $md ,
565- { use => ' signing ' },
584+ { use => $use },
566585 $x -> KeyInfo(
567586 $ds ,
568587 $x -> X509Data(
569588 $ds ,
570589 $x -> X509Certificate(
571590 $ds ,
572- $self -> _cert_text,
591+ $use eq ' signing ' ? $ self-> _cert_text : $self -> _encryption_key_text ,
573592 )
574593 ),
575594 $x -> KeyName(
576595 $ds ,
577- Digest::MD5::md5_hex($self -> _cert_text)
596+ Digest::MD5::md5_hex($use eq ' signing ' ? $ self-> _cert_text : $self -> _encryption_key_text )
578597 ),
579-
580- )
598+ ),
581599 );
582600}
583601
0 commit comments