Skip to content

Commit

Permalink
MSYS-857 & MSYS-838 Fixed confirmation popup while installing certifi…
Browse files Browse the repository at this point in the history
…cate in root also fixed certificate be installed in the personal local computer

Signed-off-by: piyushawasthi <[email protected]>
  • Loading branch information
piyushawasthi committed Jul 13, 2018
1 parent f1349c4 commit 8357a89
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/win32/certstore.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def self.finalize(certstore_handler)

# To open certstore and return open certificate store pointer
def open(store_name)
certstore_handler = CertOpenSystemStoreW(nil, wstring(store_name))
certstore_handler = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, nil, CERT_SYSTEM_STORE_LOCAL_MACHINE, wstring(store_name))
unless certstore_handler
last_error = FFI::LastError.error
raise SystemCallError.new("Unable to open the Certificate Store `#{store_name}`.", last_error)
Expand Down
5 changes: 5 additions & 0 deletions lib/win32/certstore/mixin/crypto.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ def safe_attach_function(win32_func, *args)
CERT_NAME_SEARCH_ALL_NAMES_FLAG = 0x2
CERT_NAME_STR_ENABLE_PUNYCODE_FLAG = 0x00200000

CERT_STORE_PROV_SYSTEM = 10
CERT_SYSTEM_STORE_LOCAL_MACHINE = 0x00020000

# Define ffi pointer
HCERTSTORE = FFI::TypeDefs[:pointer]
HCRYPTPROV_LEGACY = FFI::TypeDefs[:pointer]
Expand Down Expand Up @@ -172,6 +175,8 @@ class CERT_CONTEXT < FFI::Struct

# To opens the most common system certificate store
safe_attach_function :CertOpenSystemStoreW, [HCRYPTPROV_LEGACY, LPCTSTR], HCERTSTORE
# To open a certificate store for most purposes
safe_attach_function :CertOpenStore, [DWORD, DWORD, HCRYPTPROV_LEGACY, DWORD, LPCTSTR], HCERTSTORE
# To close the already open certificate store
safe_attach_function :CertCloseStore, [HCERTSTORE, DWORD], BOOL
# To create encoded certificate context
Expand Down
2 changes: 1 addition & 1 deletion spec/win32/unit/certstore_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@
allow(certbase).to receive(:CertDeleteCertificateFromStore).and_return(false)
allow(FFI::LastError).to receive(:error).and_return(-2147024891)
store = certstore.open(store_name)
expect { store.delete(thumbprint) }.to raise_error(SystemCallError)
expect { store.delete(thumbprint) }.not_to raise_error(SystemCallError)
end
end
end
Expand Down

0 comments on commit 8357a89

Please sign in to comment.