Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion ext/openssl/ossl_x509store.c
Original file line number Diff line number Diff line change
Expand Up @@ -735,10 +735,14 @@ static VALUE
ossl_x509stctx_get_curr_cert(VALUE self)
{
X509_STORE_CTX *ctx;
X509 *x509;

GetX509StCtx(self, ctx);
x509 = X509_STORE_CTX_get_current_cert(ctx);
if (!x509)
return Qnil;

return ossl_x509_new(X509_STORE_CTX_get_current_cert(ctx));
return ossl_x509_new(x509);
}

/*
Expand Down
12 changes: 12 additions & 0 deletions test/openssl/test_x509store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@ def test_verify_simple
assert_match(/ok/i, store.error_string)
assert_equal(OpenSSL::X509::V_OK, store.error)
assert_equal([ee1_cert, ca2_cert, ca1_cert], store.chain)

# Manually instantiated StoreContext
# Nothing trusted
store = OpenSSL::X509::Store.new
ctx = OpenSSL::X509::StoreContext.new(store, ee1_cert)
assert_nil(ctx.current_cert)
assert_nil(ctx.current_crl)
assert_equal(false, ctx.verify)
assert_equal(OpenSSL::X509::V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY, ctx.error)
assert_equal(0, ctx.error_depth)
assert_equal([ee1_cert], ctx.chain)
assert_equal(ee1_cert, ctx.current_cert)
end

def test_verify_callback
Expand Down
Loading