Skip to content

Support loading keys and certs from DER files #13

@timlegge

Description

@timlegge

Required for some of the interop test vectors. A simple hack that works but likely should have a is_der attribute for the object

diff --git a/lib/XML/Enc.pm b/lib/XML/Enc.pm
index 62b71bd..e756158 100644
--- a/lib/XML/Enc.pm
+++ b/lib/XML/Enc.pm
@@ -969,6 +969,10 @@ sub _load_key {
         local $/ = undef;
         $text = <$KEY>;
         close $KEY;
+        if ($file =~ m/der$/ ) {
+            my $priv = Crypt::PK::RSA->new($file);
+            $text = $priv->export_key_pem('private');
+        }
         if ( $text =~ m/BEGIN ([DR]SA) PRIVATE KEY/ ) {
             my $key_used = $1;
 

 

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions