Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support loading keys and certs from DER files #13

Open
timlegge opened this issue Dec 27, 2024 · 0 comments
Open

Support loading keys and certs from DER files #13

timlegge opened this issue Dec 27, 2024 · 0 comments
Assignees

Comments

@timlegge
Copy link
Contributor

timlegge commented Dec 27, 2024

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;
 

 
@timlegge timlegge self-assigned this Dec 27, 2024
@timlegge timlegge changed the title Support loading keys and certs from DER filels Support loading keys and certs from DER files Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant