Skip to content

Commit 710b2aa

Browse files
committed
Extract public key from cert
Very dirty temporary solution
1 parent 5caaef8 commit 710b2aa

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

prolog/jwt_io.pl

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,12 +316,23 @@
316316
memberchk(PubKeyString, Key.x5c),
317317
string_length(PubKeyString, StrLength),
318318
wrap_key(PubKeyString, 0, 64, StrLength, "", WrappedKey),
319-
format(string(PubKeyFormatted),
320-
"-----BEGIN PUBLIC KEY-----~n~s~n-----END PUBLIC KEY-----",
319+
format(string(CertFormatted),
320+
"-----BEGIN CERTIFICATE-----~n~s~n-----END CERTIFICATE-----",
321321
[WrappedKey]),
322-
tmp_file_stream(text, File, Stream),
323-
write(Stream, PubKeyFormatted),
322+
tmp_file_stream(text, FileTmpCert, TmpStreamCert),
323+
write(TmpStreamCert, CertFormatted),
324+
close(TmpStreamCert),
325+
process_create(path(openssl), ['x509', '-pubkey', '-in', FileTmpCert, '-noout'],
326+
[
327+
stdout(pipe(Stream)),
328+
detached(false),
329+
process(PID)
330+
]),
331+
tmp_file_stream(text, File, StreamTmp),
332+
copy_stream_data(Stream, StreamTmp),
333+
close(StreamTmp),
324334
close(Stream),
335+
process_wait(PID, _),
325336
atom_string(KidAtom, Key.kid),
326337
atom_string(AlgAtom, Key.alg),
327338
SettingsKey = _{kid: KidAtom,

0 commit comments

Comments
 (0)