Jump to content

Recommended Posts

Posted

i know about FIleread()

but that only read text

I need read info later encode X509.

 

Like in this file is:

Common Name: CÔNG TY CỔ PHẦN ĐẦU TƯ XÂY DỰNG VÀ THƯƠNG MẠI VIỆT HÙNG
Subject Alternative Names: email:nguyenhieu1504@gmail.com
Locality: Ba Đình
State: Hà Nội
Country: VN
Valid From: June 20, 2015
Valid To: March 25, 2018
Issuer: BkavCA, Bkav Corporation
Serial Number: 54035a78f1c607c054ae87e91ebeca6f
Posted

here will be good start (I hope)

#include <MsgBoxConstants.au3>


_Example()

Func _Example()
    ; Error monitoring. This will trap all COM errors while alive.
    ; This particular object is declared as local, meaning after the function returns it will not exist.
    Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")

    Local $oCX509PrivateKey = ObjCreate("X509Enrollment.CX509PrivateKey.1")
    If @error Then MsgBox($MB_ICONERROR, '', _
            '@error = ' & @error & @CRLF & '@extended = ' & @extended)

    Local $oCX509CertificateRequestCertificate = ObjCreate("X509Enrollment.CX509CertificateRequestCertificate")
    If @error Then MsgBox($MB_ICONERROR, '', _
            '@error = ' & @error & @CRLF & '@extended = ' & @extended)

    Local $oCSP1 = $oCX509CertificateRequestCertificate.Initialize(1)
    Local $oCSP_Coll = $oCX509CertificateRequestCertificate.CspInformations
    Local $oCSP_Unizeto = Null

    For $oCSP_enum In $oCSP_Coll
;~      ConsoleWrite('$oCX509CertificateRequestCertificate.IsSmartCard=' & $oCX509CertificateRequestCertificate.IsSmartCard & @CRLF)
        ConsoleWrite('$oCSP_enum.Name=' & $oCSP_enum.Name & @CRLF)
        ConsoleWrite('$oCSP_enum.Type=' & $oCSP_enum.Type & @CRLF)
        If $oCSP_enum.Name = 'cryptoCertum3 CSP - profil bezpieczny' Then
            $oCSP_Unizeto = $oCSP_enum
        EndIf
        ConsoleWrite('$oCSP_enum.IsSmartCard=' & $oCSP_enum.IsSmartCard & @CRLF)
        ConsoleWrite('$oCSP_enum.IsSoftwareDevice=' & $oCSP_enum.IsSoftwareDevice & @CRLF)
        ConsoleWrite('$oCSP_enum.KeySpec=' & $oCSP_enum.KeySpec & @CRLF)
        ConsoleWrite('$oCSP_enum.LegacyCsp=' & $oCSP_enum.LegacyCsp & @CRLF)
        ConsoleWrite('$oCSP_enum.Valid=' & $oCSP_enum.Valid & @CRLF)
        ConsoleWrite('$oCSP_enum.Version=' & $oCSP_enum.Version & @CRLF)
        ConsoleWrite('' & @CRLF)

    Next
;~  If @error Then MsgBox($MB_ICONERROR, '', _
            '@error = ' & @error & @CRLF & '@extended = ' & @extended)

    $oCSP_Unizeto.InitializeFromName('cryptoCertum3 CSP - profil bezpieczny')

    $oCX509PrivateKey.CspInformations = $oCSP_Coll

;~  $oCX509PrivateKey.CspInformations
    $oCX509PrivateKey.Silent = False
    $oCX509PrivateKey.ProviderName = 'cryptoCertum3 CSP - profil bezpieczny'
    $oCX509PrivateKey.ProviderType = 1
    MsgBox(0, '', $oCX509PrivateKey.SecurityDescriptor)
    $oCX509PrivateKey.Open()
;~  ConsoleWrite('$oCX509PrivateKey.CspStatus=' & $oCX509PrivateKey.CspStatus & @CRLF)
;~  ConsoleWrite('$oCX509PrivateKey.UniqueContainerName=' & $oCX509PrivateKey.UniqueContainerName & @CRLF)
;~  ConsoleWrite('$oCX509PrivateKey.UIContextMessage=' & $oCX509PrivateKey.UIContextMessage & @CRLF)
    ConsoleWrite('$oCX509PrivateKey.MachineContext=' & $oCX509PrivateKey.MachineContext & @CRLF)
;~  MsgBox(0, '', $oCX509PrivateKey.ReaderName)
;~  MsgBox(0, '', $oCX509PrivateKey.ProviderType)
;~  MsgBox(0, '', $oCX509PrivateKey.ProviderName)
;~  MsgBox(0, '', $oCX509PrivateKey.FriendlyName)
    ConsoleWrite('$oCX509PrivateKey.DefaultContainer=' & $oCX509PrivateKey.DefaultContainer & @CRLF)
    ConsoleWrite('$oCX509PrivateKey.Opened=' & $oCX509PrivateKey.Opened & @CRLF)


EndFunc    ;==>_Example



; User's COM error function. Will be called if COM error occurs
Func _ErrFunc($oError)
    ; Do anything here.
    ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _
            @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _
            @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
            @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _
            @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _
            @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
            @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
            @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
            @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
            @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF)
EndFunc    ;==>_ErrFunc


#Region  HOW TO , GUID, DOC

#cs
    http://blogs.technet.com/b/vishalagarwal/archive/2009/08/22/generating-a-certificate-self-signed-using-powershell-and-certenroll-interfaces.aspx

    Security Descriptor String Format
    https://msdn.microsoft.com/en-us/library/windows/desktop/aa379570(v=vs.85).aspx

    ACE Strings
    https://msdn.microsoft.com/en-us/library/windows/desktop/aa374928(v=vs.85).aspx

    How to create a certificate request with CertEnroll (JavaScript)
    https://blogs.msdn.microsoft.com/alejacma/2009/01/28/how-to-create-a-certificate-request-with-certenroll-javascript/
#CE

#EndRegion   HOW TO , GUID, DOC

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)
  On 3/26/2018 at 12:12 PM, tungpheng said:

i know about FIleread() but that only read text

I need read info later encode X509.

Expand  

Do you have file signed with using one of this standard: XADES / CADES / PADES ?
Or you have file in pkcs format ?

EDIT:
Try to look also here:

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  On 3/26/2018 at 12:31 PM, mLipok said:

Do you have file signed with using one of this standard: XADES / CADES / PADES ?
Or you have file in pkcs format ?

EDIT:
Try to look also here:

 

Expand  

I have file signed

I took file cer in there.

now how i can read that file from code you posted.

Sorry i just to learn code so I'm so nub. but your code upside is read cert have in system?

 

Posted

So as I understand there was a "source" file, which was signed by somebody.
You have ..... this signed file.

But do you have "source" file encapsulated/embended into signed file, or you have separate "source" file and signing file.

What extension have signed file and what extension should have "source" file ?

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

https://www.sslshopper.com/certificate-decoder.html like this website do that

I want read cert like that. but use autoit. that is text in file cer. i used base64 decode but not have full info i want.

MIIEWTCCA0GgAwIBAgIQVANaePHGB8BUrofpHr7KbzANBgkqhkiG9w0BAQUFADBJMQswCQYDVQQG
EwJWTjEOMAwGA1UEBxMFSGFub2kxGTAXBgNVBAoTEEJrYXYgQ29ycG9yYXRpb24xDzANBgNVBAMT
BkJrYXZDQTAeFw0xNTA2MjEwNjI5MTNaFw0xODAzMjYwNjI5MTNaMIGrMR4wHAYKCZImiZPyLGQB
AQwOTVNUOjAxMDIyMzk5NjgxVDBSBgNVBAMMS0PDlE5HIFRZIEPhu5QgUEjhuqZOIMSQ4bqmVSBU
xq8gWMOCWSBE4buwTkcgVsOAIFRIxq/GoE5HIE3huqBJIFZJ4buGVCBIw5lORzESMBAGA1UEB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OJ8oTf/BPtEeO3l/WTSgt
XsuQyMin+95kVkaRLrrRP5LWo+B4SWU5rBZ+zEgX61v3jg==

 

Posted
  On 3/26/2018 at 1:29 PM, mLipok said:

So as I understand there was a "source" file, which was signed by somebody.
You have ..... this signed file.

But do you have "source" file encapsulated/embended into signed file, or you have separate "source" file and signing file.

What extension have signed file and what extension should have "source" file ?

 

Expand  

that file I attached.

you can see have node <X509Certificate> .....</X509Certificate>

text in this side is file cer I want to read info.

you can copy that to notepad and change name to .cer can open and read infor by eyes but I dont know how to read by autoIT.

0100100008.xml

Posted

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

aha...
Now I know what you are searching.
Try also here:

https://redkestrel.co.uk/products/decoder/

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

I solve your problem .... partialy, I must change my UDF to show entire solution.

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)

 

 

 

Func _CertUtil_Example_Dump()
    Local $sFile1 = 'C:\1\cert.txt'
    Local $sFile2 = 'C:\1\cert2.cer'

    Local $sXML_File = FileOpenDialog('Choose XML File', @ScriptDir, 'XML Files (*.xml)')
    If @error Then Return SetError(@error, @extended, 0)

    ConsoleWrite("! $sXML_File = " & $sXML_File & @CRLF)
    Local $hFile = FileOpen($sXML_File, $FO_READ + $FO_UTF8_NOBOM)
    Local $sFileContent = FileRead($hFile)
    FileClose($hFile)

    Local $aX509Certificate = _StringBetween($sFileContent, '<X509Certificate>', '</X509Certificate>')
    If @error Then MsgBox($MB_ICONERROR, '_StringBetween', '@error = ' & @error & @CRLF & '@extended = ' & @extended)

    Local $sX509Certificate = $aX509Certificate[0]

    Local $hFile = FileOpen($sFile1, $FO_OVERWRITE + $FO_CREATEPATH + $FO_BINARY )
    FileWrite($hFile, '-----BEGIN CERTIFICATE-----' & @CRLF & $sX509Certificate & @CRLF & '-----END CERTIFICATE-----')
    FileClose($hFile)

    _CertUtil_ConvertToBinary($sFile1, $sFile2)
    If @error Then MsgBox($MB_ICONERROR, '_CertUtil_ConvertToBinary', '@error = ' & @error & @CRLF & '@extended = ' & @extended)

    Local $sResult = _CertUtil_Dump($sFile2)
    If @error Then MsgBox($MB_ICONERROR, '_CertUtil_Dump', '@error = ' & @error & @CRLF & '@extended = ' & @extended)

    MsgBox(0, '$sResult', $sResult)

    ClipPut($sResult)

EndFunc   ;==>_Example

Result:

  Reveal hidden contents

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

This was one of many things that I had on my private:   AutoIt TODO list.

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

before ask about that. I have found this command 

  Quote

openssl x509 -in acs.qacafe.com.pem -text

Expand  

but I dont know how to use that. and now see you UDF I know more 1 things I asked more about StdoutRead never  used

Thank you again

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...