How to extract public key from X509 certificate in javascript or angular 2

1,449 views
Skip to first unread message

pratik pandey

unread,
Apr 6, 2018, 11:42:53 AM4/6/18
to Angular and AngularJS discussion
-----BEGIN CERTIFICATE-----\r\nMIIFkTCCBHmgAwIBAgIEAOATLTANBgkqhkiG9w0BAQsFADCBkDELMAkGA1UEBhMC\r\nSU4xKjAoBgNVBAoTIWVNdWRocmEgQ29uc3VtZXIgU2VydmljZXMgTGltaXRlZDEd\r\nMBsGA1UECxMUQ2VydGlmeWluZyBBdXRob3JpdHkxNjA0BgNVBAMTLWUtTXVkaHJh\r\nIFN1YiBDQSBmb3IgQ2xhc3MgMyBPcmdhbmlzYXRpb24gMjAxNDAeFw0xNzEwMzEx\r\nMzQwNTNaFw0yMDEwMzAxMzQwNTNaMIG+MQswCQYDVQQGEwJJTjEOMAwGA1UEChMF\r\nVUlEQUkxGjAYBgNVBAsTEVRlY2hub2xvZ3kgQ2VudHJlMQ8wDQYDVQQREwY1NjAw\r\nOTIxEjAQBgNVBAgTCUthcm5hdGFrYTFJMEcGA1UEBRNAODdiNzU2ZjQ5ZWZlY2Jh\r\nMTczNzllOTY5N2JhMmNmMzFkYTdlOGY4NGE2ZThmNGRhOGQwNWIxODNmYjVkMWFk\r\nOTETMBEGA1UEAxMKQW51cCBLdW1hcjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC\r\nAQoCggEBAOlums2zjLx4cBx7MJGSN2hunAo3wuRu9Tk5bSkstTmIo4/Som8st2H5\r\nZy9YBpWNuqkT29LCqtzvJKu1WLClnRyrIWuEVxCerdJCb9+PXjjZwdUIIrGMyo0r\r\nUzysN62ybPhYeC1Ab+eQge9JEmQsdrJJ9Mya3A/9/FdVPRG3pIPu9tvodYedtt/I\r\nlhhDzzC7wfKKHXDY8ydU06anf+StC3GPiroqNHVKOWTI3ZiYKk9Qxnw9lOc3w4Ty\r\nfYSO/NR3/2OeFfjFva+uJrnm2rBZmlb+ScmIkuY13os7OFA9vjLPiGkjCOpAaQZD\r\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AQlE0G/VTsEiugxig==\r\n-----END CERTIFICATE-----




how to extract public key from above certificate in angular 2 or javascript

Sander Elias

unread,
Apr 7, 2018, 2:57:41 AM4/7/18
to Angular and AngularJS discussion
Hi Pratik,

Have a look at PKIjs

Regards
Sander

pratik pandey

unread,
Apr 7, 2018, 11:29:00 AM4/7/18
to ang...@googlegroups.com
Tried this also bt didn't worked 
..it's saying that it's not a function or undefined
....

--
You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Sander Elias

unread,
Apr 7, 2018, 9:34:51 PM4/7/18
to Angular and AngularJS discussion
Hi Pratik,

Probably you used NPM to get it. As far as i know, there is no correct working @types fie for the thing. Enable Aloowjs is your tsconfig, and import it something like this:
import * as PKI from "pkijs"

I don't have time now to build a sample.

Regards
Sander

pratik pandey

unread,
Apr 9, 2018, 1:02:57 AM4/9/18
to ang...@googlegroups.com
Hi Sander,

What i have done is NPM i PKIJS.
After which i got this in my package.json-lock

"pkijs": {
"version": "2.1.36",
"integrity": "sha512-AlFMOtvh00xK3+iXxz3zRiHeGoStj58OQlV9gKrnqjvfG1mEzyxddRAwQNtvn2enSrtFrgP4IpIgDaUwE/aDLQ==",
"requires": {
"asn1js": "2.0.19",
"pvutils": "1.0.12"
}
},

After this i used this to import in my ts file
import Certificate from "pkijs";

but when i call   Certificate. something
its shows undefined function.



Pplease Help If possible.

--
You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe@googlegroups.com.

pratik pandey

unread,
Apr 9, 2018, 1:22:31 AM4/9/18
to ang...@googlegroups.com
Also Sander,

Can you tell me the steps to include things the way you are saying.
or share some sample.
Reply all
Reply to author
Forward
0 new messages