@@ -157,7 +157,7 @@ Consumer Services.
157157
158158has ' url' => (isa => Uri, is => ' ro' , required => 1, coerce => 1);
159159has ' id' => (isa => ' Str' , is => ' ro' , required => 1);
160- has ' cert' => (isa => ' Str' , is => ' ro' , required => 1);
160+ has ' cert' => (isa => ' Str' , is => ' ro' , required => 1, predicate => ' has_cert ' );
161161has ' key' => (isa => ' Str' , is => ' ro' , required => 1);
162162has ' cacert' => (isa => ' Str' , is => ' rw' , required => 0, predicate => ' has_cacert' );
163163
@@ -274,6 +274,7 @@ around BUILDARGS => sub {
274274sub _build_encryption_key_text {
275275 my ($self ) = @_ ;
276276
277+ return ' ' unless $self -> has_encryption_key;
277278 my $cert = Crypt::OpenSSL::X509-> new_from_file($self -> encryption_key);
278279 my $text = $cert -> as_string;
279280 $text =~ s / -----[^-]*-----// gm ;
@@ -283,6 +284,7 @@ sub _build_encryption_key_text {
283284sub _build_cert_text {
284285 my ($self ) = @_ ;
285286
287+ return ' ' unless $self -> has_cert;
286288 my $cert = Crypt::OpenSSL::X509-> new_from_file($self -> cert);
287289 my $text = $cert -> as_string;
288290 $text =~ s / -----[^-]*-----// gm ;
@@ -634,11 +636,25 @@ sub _generate_key_descriptors {
634636 $x -> KeyInfo(
635637 $ds ,
636638 $x -> X509Data($ds , $x -> X509Certificate($ds , $key )),
637- $x -> KeyName($ds , Digest::MD5::md5_hex( $key )),
639+ $x -> KeyName($ds , $self -> key_name( $use )),
638640 ),
639641 );
640642}
641643
644+ =head2 key_name($type)
645+
646+ Get the key name for either the C<signing > or C<encryption > key
647+
648+ =cut
649+
650+ sub key_name {
651+ my $self = shift ;
652+ my $use = shift ;
653+ my $key = $use eq ' signing' ? $self -> _cert_text : $self -> _encryption_key_text;
654+ return unless $key ;
655+ return Digest::MD5::md5_hex($key );
656+ }
657+
642658sub _generate_single_logout_service {
643659 my $self = shift ;
644660 my $x = shift ;
0 commit comments