Strict Standards: Redefining already defined constructor for class wpdb in /var/www/myfoto.se/jbits.se/blog/wp-includes/wp-db.php on line 56

Deprecated: Assigning the return value of new by reference is deprecated in /var/www/myfoto.se/jbits.se/blog/wp-includes/cache.php on line 36

Strict Standards: Redefining already defined constructor for class WP_Object_Cache in /var/www/myfoto.se/jbits.se/blog/wp-includes/cache.php on line 384

Strict Standards: Declaration of Walker_Page::start_lvl() should be compatible with Walker::start_lvl($output) in /var/www/myfoto.se/jbits.se/blog/wp-includes/classes.php on line 541

Strict Standards: Declaration of Walker_Page::end_lvl() should be compatible with Walker::end_lvl($output) in /var/www/myfoto.se/jbits.se/blog/wp-includes/classes.php on line 541

Strict Standards: Declaration of Walker_Page::start_el() should be compatible with Walker::start_el($output) in /var/www/myfoto.se/jbits.se/blog/wp-includes/classes.php on line 541

Strict Standards: Declaration of Walker_Page::end_el() should be compatible with Walker::end_el($output) in /var/www/myfoto.se/jbits.se/blog/wp-includes/classes.php on line 541

Strict Standards: Declaration of Walker_PageDropdown::start_el() should be compatible with Walker::start_el($output) in /var/www/myfoto.se/jbits.se/blog/wp-includes/classes.php on line 560

Strict Standards: Declaration of Walker_Category::start_lvl() should be compatible with Walker::start_lvl($output) in /var/www/myfoto.se/jbits.se/blog/wp-includes/classes.php on line 659

Strict Standards: Declaration of Walker_Category::end_lvl() should be compatible with Walker::end_lvl($output) in /var/www/myfoto.se/jbits.se/blog/wp-includes/classes.php on line 659

Strict Standards: Declaration of Walker_Category::start_el() should be compatible with Walker::start_el($output) in /var/www/myfoto.se/jbits.se/blog/wp-includes/classes.php on line 659

Strict Standards: Declaration of Walker_Category::end_el() should be compatible with Walker::end_el($output) in /var/www/myfoto.se/jbits.se/blog/wp-includes/classes.php on line 659

Strict Standards: Declaration of Walker_CategoryDropdown::start_el() should be compatible with Walker::start_el($output) in /var/www/myfoto.se/jbits.se/blog/wp-includes/classes.php on line 684

Deprecated: Assigning the return value of new by reference is deprecated in /var/www/myfoto.se/jbits.se/blog/wp-includes/query.php on line 21

Deprecated: Assigning the return value of new by reference is deprecated in /var/www/myfoto.se/jbits.se/blog/wp-content/plugins/code-highlighter/codehighlighter.php on line 42
jbits.se » 2009 » April » 03
Deprecated: preg_replace() [function.preg-replace]: The /e modifier is deprecated, use preg_replace_callback instead in /var/www/myfoto.se/jbits.se/blog/wp-includes/kses.php on line 627

jbits.se

Jörgen Björkmans blog

Archive for April 3rd, 2009

Apr
03

Cert Backup

Posted by jbjorkman on April 3, 2009 under
Deprecated: preg_replace() [function.preg-replace]: The /e modifier is deprecated, use preg_replace_callback instead in /var/www/myfoto.se/jbits.se/blog/wp-includes/formatting.php on line 82
VBScript, Windows

Option Explicit
'************ You have to have capicom.dll downloaded and registered...
on error resume next
Const SavePath="C:\System\ISA-Backups\Certs\"
Const CAPICOM_CERTIFICATE_SAVE_AS_PFX = 0
Const CAPICOM_CURRENT_USER_STORE  = 2
Const CAPICOM_EKU_CLIENT_AUTH = 2
Const CAPICOM_EKU_CODE_SIGNING = 3
Const CAPICOM_EKU_EMAIL_PROTECTION = 4
Const CAPICOM_EKU_SERVER_AUTH = 1
Const CAPICOM_EKU_OTHER = 0
Const CAPICOM_EXPORT_DEFAULT = 0
Const CAPICOM_CERTIFICATE_INCLUDE_CHAIN_EXCEPT_ROOT = 0
Const CAPICOM_CERTIFICATE_INCLUDE_WHOLE_CHAIN = 1
Const CAPICOM_CERTIFICATE_INCLUDE_END_ENTITY_ONLY = 2
Const CAPICOM_LOCAL_MACHINE_STORE  = 1
Const CAPICOM_MY_STORE = "My"
Const CAPICOM_STORE_OPEN_EXISTING_ONLY = 128
Const CAPICOM_STORE_OPEN_READ_ONLY = 0
Const CAPICOM_STORE_SAVE_AS_PFX = 2
Const CR_DISP_ISSUED  = &H3
Const CR_OUT_CHAIN = &H100
Const CR_OUT_BASE64 = &H1
Const CERT_SYSTEM_STORE_LOCAL_MACHINE = &H20000
Const CR_IN_BASE64  = &H1
Const CR_IN_PKCS10  = &H100

Dim oCert, oStore
Dim strDate
Dim strCmp
Dim strCertName
Dim strfname
Dim strPasswd

Set oStore = CreateObject ("CAPICOM.Store")
if Err.Number <> 0 Then
wscript.echo "CAPICOM NOT detected"
Wscript.Quit(1)
End if

StrDate=Year(Now) & "-" & right("0" & Month(Now),2) & "-" & right("0" & Day(Now),2)
StrCmp=WScript.CreateObject("WScript.Network").ComputerName

oStore.Open CAPICOM_LOCAL_MACHINE_STORE, CAPICOM_MY_STORE, CAPICOM_STORE_OPEN_READ_ONLY

strPasswd=Inputbox("Enter password to encrypt pfx with")

For Each oCert in oStore.Certificates
strCertName=left(oCert.SubjectName,instr(oCert.SubjectName,",")-1)
strCertName=replace(strCertName,"CN=","")
strCertName=replace(strCertName,"OU=","")
strCertName=replace(strCertName,"*","x")
strCertName=replace(strCertName," ","-")
strCertName=replace(strCertName,".","-")

strfname=strCmp & "-" & left(oCert.ValidtoDate,10) & "-" & strCertName

oCert.Save savePath & strfname & ".pfx", strPasswd, CAPICOM_CERTIFICATE_SAVE_AS_PFX, CAPICOM_CERTIFICATE_INCLUDE_WHOLE_CHAIN
Next