
Gertsen
Members-
Posts
9 -
Joined
-
Last visited
Everything posted by Gertsen
-
Hello Ultima - I have a question about using your fine functions here, I want to check the expiration date of a SSL-certificate on a remote server, first I tried the CAPICOM dll, but so far I have only been able to check local certificates using that. In MSDN documentation, I see that WinINet has a struct called INTERNET_CERTIFICATE_INFO - I'm not sure how to use/access this struct, or if it's even possible using your functions? Also I'm not even sure if this can be used for the purpose I had in mind, but I'm hoping you can shed some light on that? You can see my attempts so far here: http://www.autoitscript.com/forum/index.ph...mp;#entry592517
-
I played around with Ultima's fine functions, and so far I have arrived at the code below. I can now open a connection to a remote ssl server, but I still have no idea how to access the INTERNET_CERTIFICATE_INFO struct :-( Any ideas? #include <WinINet.au3> ; Initialize WinINet _WinINet_Startup() ; Set variables Global $sServerName = "mail.google.com" Global $iServerPort = 443 Global $sUsername = Default Global $sPassword = Default ; Create handles ConsoleWrite("Opening Internet connection ..." & @LF) Global $hInternetOpen = _WinINet_InternetOpen("AutoIt/" & @AutoItVersion) if @error Then ConsoleWrite("Open Internet connection: failed." & @LF) Else ConsoleWrite("Open Internet connection: ok." & @LF) EndIf ConsoleWrite("Connecting to " & $sServerName & ":" & $iServerPort & " ..." & @LF) Global $hInternetConnect = _WinINet_InternetConnect($hInternetOpen, $INTERNET_SERVICE_HTTP, $sServerName, $iServerPort, 0, $sUsername, $sPassword) if @error Then ConsoleWrite("Connect to " & $sServerName & ":" & $iServerPort & ": failed." & @LF) Else ConsoleWrite("Connect to " & $sServerName & ":" & $iServerPort & ": ok." & @LF) EndIf ; Cleanup _WinINet_InternetCloseHandle($hInternetConnect) _WinINet_InternetCloseHandle($hInternetOpen) _WinINet_Shutdown() ConsoleWrite("End of program..." & @LF)
-
According to MSDN, WinINet has a struct called INTERNET_CERTIFICATE_INFO, but I have no idea how to use/access it. Have you tried using WinINet before, perhaps you have some hints?
-
Hmm it seems I found my certificate in the $CAPICOM_CURRENT_USER_STORE store - the certificate for my own domain-user from the domain, that is. I still can't seem to access certificates on other servers or sites. Perhaps capicom just isn't the way to go? Or perhaps something else needs to be done with capicom first, there are alot of terms in capicom I don't understand, like "IOU" and "Chains" and lots more...
-
Updated to show a nicer date, and calculate how many days remain before expiration. Now I "just" need it to be able to check certificates on other servers, not just my local pc. #Include <Date.au3> Global Const $CAPICOM_CERTIFICATE_FIND_SUBJECT_NAME = 1 Global Const Enum $CAPICOM_ACTIVE_DIRECTORY_USER_STORE, _ $CAPICOM_CURRENT_USER_STORE, _ $CAPICOM_LOCAL_MACHINE_STORE, _ $CAPICOM_MEMORY_STORE, _ $CAPICOM_SMART_CARD_USER_STORE Global Const Enum $CAPICOM_STORE_OPEN_MAXIMUM_ALLOWED, _ $CAPICOM_STORE_OPEN_READ_ONLY, _ $CAPICOM_STORE_OPEN_READ_WRITE $Store = ObjCreate("CAPICOM.Store") $Store.Open($CAPICOM_LOCAL_MACHINE_STORE, "My", $CAPICOM_STORE_OPEN_READ_ONLY) $Certificates = $Store.Certificates.Find($CAPICOM_CERTIFICATE_FIND_SUBJECT_NAME, "mage", 0) For $Certificate in $Certificates ConsoleWrite("Valid From: " & _FixDate($Certificate.ValidFromDate) & @LF) ConsoleWrite("Valid To: " & _FixDate($Certificate.ValidToDate) & @LF) ConsoleWrite("Subject Name: " & $Certificate.SubjectName & @LF) ConsoleWrite("Issued By: " & $Certificate.IssuerName & @LF) $test = _DateDiff("D",_FixDate($Certificate.ValidFromDate),_FixDate($Certificate.ValidToDate)) ConsoleWrite("Days remaining: " & $test & @LF) Next Func _FixDate($inDate) Return StringMid($inDate,1,4) & "/" & StringMid($inDate,5,2) & "/" & StringMid($inDate,7,2) EndFunc ;==>_FixDate
-
Hmm I got this working, but it will only check my own domain user-account (in this case "mage")... Any ideas on how to get it to check external servers (though still on this LAN) ? Global Const $CAPICOM_CERTIFICATE_FIND_SUBJECT_NAME = 1 Global Const Enum $CAPICOM_ACTIVE_DIRECTORY_USER_STORE, _ $CAPICOM_CURRENT_USER_STORE, _ $CAPICOM_LOCAL_MACHINE_STORE, _ $CAPICOM_MEMORY_STORE, _ $CAPICOM_SMART_CARD_USER_STORE Global Const Enum $CAPICOM_STORE_OPEN_MAXIMUM_ALLOWED, _ $CAPICOM_STORE_OPEN_READ_ONLY, _ $CAPICOM_STORE_OPEN_READ_WRITE $Store = ObjCreate("CAPICOM.Store") $Store.Open($CAPICOM_LOCAL_MACHINE_STORE, "My", $CAPICOM_STORE_OPEN_READ_ONLY) $Certificates = $Store.Certificates.Find($CAPICOM_CERTIFICATE_FIND_SUBJECT_NAME, "mage", 0) For $Certificate in $Certificates ConsoleWrite("Valid From: " & $Certificate.ValidFromDate & @LF) ConsoleWrite("Valid To: " & $Certificate.ValidToDate & @LF) ConsoleWrite("Subject Name: " & $Certificate.SubjectName & @LF) ConsoleWrite("Issued By: " & $Certificate.IssuerName & @LF) Next Output: >"C:\Programmer\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "U:\Dokumenter\AutoIt\sslcheck\sslcheck2.au3" Valid From: 20081008091309 Valid To: 20091008091309 Subject Name: CN=mage, OU=TestOY, OU=Users, DC=TestDomain, DC=dk Issued By: CN=Test, DC=TestDomain, DC=dk >Exit code: 0 Time: 0.223
-
I found this script though: http://weblogs.asp.net/mikedopp/archive/20...tom-script.aspx Only I can't seem to translate the "For each" loop it uses (I'm new to AutoIt's language) Also it only seems to be able to see the certificates installed on my local computer, not the remote servers, but I hope I can change that once I get the script working better. Here is what I have so far, though it dosen't work yet.. #include <INet.au3> Global Const $CAPICOM_LOCAL_MACHINE_STORE_TEST = 1 Global Const $CAPICOM_CERTIFICATE_FIND_SUBJECT_NAME = 1 Global Const $CAPICOM_STORE_OPEN_READ_ONLY_TEST = 0 Global Const Enum $CAPICOM_ACTIVE_DIRECTORY_USER_STORE, _ $CAPICOM_CURRENT_USER_STORE, _ $CAPICOM_LOCAL_MACHINE_STORE, _ $CAPICOM_MEMORY_STORE, _ $CAPICOM_SMART_CARD_USER_STORE Global Const Enum $CAPICOM_STORE_OPEN_MAXIMUM_ALLOWED, _ $CAPICOM_STORE_OPEN_READ_ONLY, _ $CAPICOM_STORE_OPEN_READ_WRITE $Store = ObjCreate("CAPICOM.Store") ;$Store.Open($CAPICOM_LOCAL_MACHINE_STORE, "CAPICOM_MY_STORE", $CAPICOM_STORE_OPEN_READ_ONLY) $Store.Open($CAPICOM_LOCAL_MACHINE_STORE_TEST, "My", $CAPICOM_STORE_OPEN_READ_ONLY_TEST) $Certificates = $Store.Certificates.Find($CAPICOM_CERTIFICATE_FIND_SUBJECT_NAME, "mail.google.com", 0) For Each $Certificate in $Certificates ConsoleWrite("-->" & $Certificate.ValidFromDate & @LF) Next I get the following error: >"C:\Programmer\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "U:\Dokumenter\AutoIt\sslcheck\sslcheck2.au3" U:\Dokumenter\AutoIt\sslcheck\sslcheck2.au3 (24) : ==> "For" statement is badly formatted.: For Each $Certificate in $Certificates For ^ ERROR >Exit code: 1 Time: 0.333 So clearly the For Each dosen't work :-(
-
I found that one in my search too, but it's way beyond my abilities to translate that to AutoIt :-/
-
I need a script that reads a remote SSL certificate, and gives me access to information about it, like expiration date. Other info I would like, but can live without is: IssuerCertificate Name (CN)Valid from (date)Expiration (date)Domain (what the certificate is issued for)Other misc infoI tried using winhttp.winhttprequest.5.1 and Msxml2.ServerXMLHTTP.3.0 but they only seem to be able to connect to SSL servers, not accually read the certificate itself?I can get them to give an error message if the certificate has expired, but by then it is too late The reason I need this, is that it's quite bad when an SSL certificate expires, so I often need to check the expiration date of alot of certificates, and it would take a long time to manually open each site in IE or similar, to lookup the date... So I want to make a tool that checks the expiration date, and sends me a mail if there is a month or less left before it expires. I can figure out the rest of the program myself, it's getting the certificate information that is holding me back