は、私がtest/1
を呼び出す場合、このコードは7.5.9で7.5.3-1-g647ce9aが、休憩で動作https://stackoverflow.com/a/44524628?noredirect=1Swiの最新バージョンで異なる署名チェーンの確認SWI-Prolog?
:-use_module(library(http/http_client)).
:-use_module(library(http/http_open)).
:-use_module(library(clpfd)).
url2('https://s3.amazonaws.com/echo.api/echo-api-cert-4.pem').
get_pem(Url,Certs):-
setup_call_cleanup(
http_open(Url,Stream,[]),
ssl_peer_certificate_chain(Stream,Certs),
close(Stream)
).
test(Key):-
url2(U),
get_pem(U,[A|Certs]),
checkcertvalid_time(A),
checkchain([A|Certs]),
memberchk(key(Key),A).
checkcertvalid_time(Acert):-
%what about The domain echo-api.amazon.com is present in the Subject Alternative Names (SANs) section of the signing certificate
memberchk(notbefore(NotBefore),Acert),
memberchk(notafter(NotAfter),Acert),
get_time(NowA),
Now is round(NowA),
Now #>NotBefore,
Now #<NotAfter.
checkchain(Chain):-
length(Chain,L),
L#>1, %Insure chain has more than one cert
checkchain_h(Chain).
checkchain_h([_]). %Reached the root.
checkchain_h([C1,C2|Rest]):-
memberchk(signature(Sig),C1),
memberchk(to_be_signed(Signed),C1),
memberchk(key(Key),C2),
hex_bytes(Signed,Bytes),
crypto_data_hash(Bytes,Hash,[algorithm(sha256),encoding(octet)]),
rsa_verify(Key,Hash,Sig,[type(sha256)]),
checkchain_h([C2|Rest]).
からフォローアップ。 7.537ではmemberchk(to_be_signed(Signed),C1)
が呼び出されたときにcheckchain_h/1
が失敗します。
これは、同じコンピュータではない2台の別のコンピュータでテストされています。この違いを引き起こす可能性のある外部ソフトウェアはありますか?
さらに、私が知る限り、私が見ることができない 'subject_alternative_name'のフィールドもあるはずです。
更新: 7.5.9オン:7.5.3-1-g647ce9aオン
OpenSSL 1.0.1t 3 May 2016
?- use_module(library(ssl)), current_prolog_flag(ssl_library_version, V).
V = 'OpenSSL 1.0.1t 3 May 2016'.
:
OpenSSL 1.0.2g 1 Mar 2016
?- use_module(library(ssl)), current_prolog_flag(ssl_library_version, V).
V = 'OpenSSL 1.0.2g 1 Mar 2016'.
両方のシステムとクエリの出力に '$ openssl version'の出力を追加してください:'? - use_module(library(ssl))、current_prolog_flag(ssl_library_version、V).' – mat
私はその情報を追加しました。 – user27815