📄 cview.vbs
字号:
Wscript.Stdout.Write ", "
End If
Wscript.Stdout.Write CStr(Qualifier.NoticeNumbers.Item(nIndex))
Next
End If
Wscript.Stdout.Writeline
Wscript.Stdout.Writeline " Explicit text = " & Qualifier.ExplicitText
Next
Wscript.Stdout.Writeline
Next
Case Else
' We don't have the decoder, so can't do much.
End Select
End If
Next
If iIndex = 0 Then
Wscript.Stdout.Writeline "Extension: None."
Wscript.Stdout.Writeline
End If
iIndex = 0
Dim ExtendedProperty
For Each ExtendedProperty In Certificate.ExtendedProperties
iIndex = iIndex + 1
Wscript.Stdout.Writeline "Property #" & CStr(iIndex) & " (ID = " & ExtendedProperty.PropID & "):"
Wscript.Stdout.Writeline " " & ExtendedProperty.Value
Next
If iIndex = 0 Then
Wscript.Stdout.Writeline "Property: None."
Wscript.Stdout.Writeline
End If
End If
On Error Goto 0
End Sub ' End DisplayCertificate
'******************************************************************************
'
' Function : IsReDimed
'
' Synopsis : Check to see if an array has any element.
'
' Parameter : Array - array to check.
'
' Return : True if contains element, else False.
'
'******************************************************************************
Function IsReDimed (Array)
On Error Resume Next
Dim i : i = LBound(Array)
If Err.Number = 0 Then
IsReDimed = True
Else
IsReDimed = False
End If
On Error Goto 0
End Function ' End IsReDimed
'******************************************************************************
'
' Subroutine: ParseCommandLine
'
' Parameter : None
'
' Synopsis : Parse the command line, and set the options accordingly.
'
'******************************************************************************
Sub ParseCommandLine
' Constants for command line parsing states.
Const ARG_STATE_OPTIONS = 0
Const ARG_STATE_CHAIN = 1
Const ARG_STATE_USAGE = 2
Const ARG_STATE_POLICY = 3
Const ARG_STATE_VALIDITY = 4
Const ARG_STATE_TIMEOUT = 5
Const ARG_STATE_PASSWORD = 6
Const ARG_STATE_END = 7
' Our command line parsing state's variable.
Dim ArgState : ArgState = ARG_STATE_OPTIONS
' Parse comman line.
Dim Arg
For Each Arg In Wscript.Arguments
Select Case ArgState
Case ARG_STATE_OPTIONS
Select Case UCase(Arg)
Case "-CHAIN", "/CHAIN"
ArgState = ARG_STATE_CHAIN
Case "-EKU", "/EKU"
ArgState = ARG_STATE_USAGE
Case "-POLICY", "/POLICY"
ArgState = ARG_STATE_POLICY
Case "-VALIDITY", "/VALIDITY"
ArgState = ARG_STATE_VALIDITY
Case "-TIMEOUT", "/TIMEOUT"
ArgState = ARG_STATE_TIMEOUT
Case "-V", "/V"
Verbose = TRUE
Case "-?", "/?"
DisplayUsage
Case "~?"
ExtendedHelp = True
DisplayUsage
Case Else
If Left(Arg, 1) = "-" OR Left(Arg, 1) = "/" Then
DisplayUsage
Else
CertFile = Arg
End If
ArgState = ARG_STATE_PASSWORD
End Select
Case ARG_STATE_CHAIN
If Left(Arg, 1) = "-" OR Left(Arg, 1) = "/" Then
DisplayUsage
Else
CheckFlag = CLng(Arg)
End If
ArgState = ARG_STATE_OPTIONS
Case ARG_STATE_USAGE
If Left(Arg, 1) = "-" OR Left(Arg, 1) = "/" Then
DisplayUsage
Else
If IsReDimed(Usages) Then
ReDim Preserve Usages(UBound(Usages) + 1)
Else
ReDim Usages(0)
End If
Usages(UBound(Usages)) = Arg
End If
ArgState = ARG_STATE_OPTIONS
Case ARG_STATE_POLICY
If Left(Arg, 1) = "-" OR Left(Arg, 1) = "/" Then
DisplayUsage
Else
If IsReDimed(Policies) Then
ReDim Preserve Policies(UBound(Policies) + 1)
Else
ReDim Policies(0)
End If
Policies(UBound(Policies)) = Arg
End If
ArgState = ARG_STATE_OPTIONS
Case ARG_STATE_VALIDITY
If Left(Arg, 1) = "-" OR Left(Arg, 1) = "/" Then
DisplayUsage
Else
VerificationTime = CDate(Arg)
End If
ArgState = ARG_STATE_OPTIONS
Case ARG_STATE_TIMEOUT
If Left(Arg, 1) = "-" OR Left(Arg, 1) = "/" Then
DisplayUsage
Else
UrlRetrievalTimeout = CLng(Arg)
End If
ArgState = ARG_STATE_OPTIONS
Case ARG_STATE_PASSWORD
If Left(Arg, 1) = "-" OR Left(Arg, 1) = "/" Then
DisplayUsage
Else
Password = Arg
End If
ArgState = ARG_STATE_END
Case Else
DisplayUsage
End Select
Next
' Make sure filename is provided.
If IsNull(CertFile) = True Then
DisplayUsage
End If
End Sub ' ParseCommandLine
'******************************************************************************
'
' Subroutine: DisplayUsage
'
' Synopsis : Display the usage screen, and then exit with a negative error
' code.
'
' Parameter : None.
'
' Remark : Display example usages if the global variable ExtendedHelp is set
' to True.
'
'******************************************************************************
Sub DisplayUsage
Wscript.Stdout.Writeline "Usage: CView [Options] CertFile [Password]"
Wscript.Stdout.Writeline
Wscript.Stdout.Writeline "Options:"
Wscript.Stdout.Writeline
Wscript.Stdout.Writeline " -chain <value> -- Check flag in hex value (Default is no check)"
Wscript.Stdout.Writeline " -eku <name | oid> ** EKU name or OID"
Wscript.Stdout.Writeline " -policy <name | oid> ** Certificate policy name or OID"
Wscript.Stdout.Writeline " -validity <date/time> -- Validity verification date/time"
Wscript.Stdout.Writeline " -timeout <seconds> -- CRL retrieval timeout value"
Wscript.Stdout.Writeline " -v -- Verbose operation"
Wscript.Stdout.Writeline " -? -- This help screen"
Wscript.Stdout.Writeline
Wscript.Stdout.Writeline " CertFile -- CER or PFX file path"
Wscript.Stdout.Writeline
Wscript.Stdout.Writeline " Password -- Password to decrypt the PFX file"
Wscript.Stdout.Writeline
Wscript.Stdout.Writeline "Note: All non-fatal invalid options will be ignored, and the ** symbol"
Wscript.Stdout.Writeline " indicates option can be listed multiple times."
Wscript.Stdout.Writeline
If ExtendedHelp Then
Wscript.Stdout.Writeline "Examples:"
Wscript.Stdout.Writeline
Wscript.Stdout.Writeline " cview MyCert.cer"
Wscript.Stdout.Writeline
Wscript.Stdout.Writeline " cview -chain ""&H000001EF"" -validity 03/18/2001 MyCert.cer"
Wscript.Stdout.Writeline
Wscript.Stdout.Writeline " cview -chain ""&H000001F7"" -timeout 30 MyCert.cer"
Wscript.Stdout.Writeline
Wscript.Stdout.Writeline " cview -chain ""&H000001EF"" -policy ""medium assurance"" MyCert.cer"
Wscript.Stdout.Writeline
Wscript.Stdout.Writeline " cview -chain ""&H000001F7"" -eku ""code signing"" -eku 1.3.6.1.5.5.7.3.4 MyPfx.pfx MyPwd"
Wscript.Stdout.Writeline
Wscript.Stdout.Writeline " cview -chain ""&H0000002F"" -eku ""secure email"" -policy ""high assurance"" MyCert.cer"
End If
Wscript.Quit(1)
End Sub ' End DisplayUsage
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -