REM =========================================================== REM GetCert.CMD REM Requests, retrieves and installs a client/server authentication certificate from the datacenter region-specific Rackspace Infrastructure Certificate Authority, and gets and installs the Root CA cert so this CA is trusted. REM Version 1.0 REM March, 2009 REM =========================================================== @echo off if {%1} equ {/?} goto USAGE if {%1} equ {-?} goto USAGE if {%1} equ {?} goto USAGE if {%1} equ {} goto USAGE if {%2} equ {/?} goto USAGE if {%2} equ {-?} goto USAGE if {%2} equ {?} goto USAGE if {%2} equ {} goto USAGE set subjectname=%1 set GeographicRegion=%2 set certpath=%systemdrive%\OMCertificates mkdir %certpath% if {%2} equ {SAT} goto SAT if {%2} equ {DFW} goto DFW if {%2} equ {LON} goto LON if {%2} equ {HKG} goto DFW if {%2} equ {IAD} goto IAD REM batch file will proceed to SAT if no match. SAT will test for not equal catch-all if an invalid datacenter region is entered. rem Get the CA's cert pause :SAT if {%2} neq {SAT} goto USAGE certutil -f -config "SATRackCA.rackspace.com\SATRack-SubCA" -ca.chain %certpath%\RSInfraCerts.p7b goto ADDSTORE :DFW certutil -f -config "DFWRackCA.rackspace.com\DFWRack-SubCA" -ca.chain %certpath%\RSInfraCerts.p7b goto ADDSTORE :LON certutil -f -config "LONRackCA.rackspace.com\LONRack-SubCA" -ca.chain %certpath%\RSInfraCerts.p7b goto ADDSTORE :IAD certutil -f -config "IADRackCA.rackspace.com\IADRack-SubCA" -ca.chain %certpath%\RSInfraCerts.p7b goto ADDSTORE :ADDSTORE rem Insert the CA's cert to the "Trusted Root Authorities" store certutil -f -addstore Root %certpath%\RSInfraCerts.p7b Pause rem Create an INF request file with the specified subjectname del %certpath%\%subjectname%.inf echo [NewRequest] > %certpath%\%subjectname%.inf echo Subject="CN=%subjectname%" >> %certpath%\%subjectname%.inf echo Exportable=TRUE >> %certpath%\%subjectname%.inf echo KeyLength=1024 >> %certpath%\%subjectname%.inf echo KeySpec=1 >> %certpath%\%subjectname%.inf echo KeyUsage=0xf0 >> %certpath%\%subjectname%.inf echo MachineKeySet=TRUE >> %certpath%\%subjectname%.inf echo [EnhancedKeyUsageExtension] >> %certpath%\%subjectname%.inf echo OID=1.3.6.1.5.5.7.3.1 >> %certpath%\%subjectname%.inf echo OID=1.3.6.1.5.5.7.3.2 >> %certpath%\%subjectname%.inf rem Create a binary request file from the INF del %certpath%\%subjectname%.req CertReq -New -f %certpath%\%subjectname%.inf %certpath%\%subjectname%.req rem Submit the request to our CA and save the certificate if {%2} equ {SAT} goto SAT-Request if {%2} equ {DFW} goto DFW-Request if {%2} equ {LON} goto LON-Request if {%2} equ {HKG} goto DFW-Request if {%2} equ {IAD} goto IAD-Request :SAT-Request CertReq -Submit -f -config "SATRackCA.rackspace.com\SATRack-SubCA" %certpath%\%subjectname%.req %certpath%\%subjectname%.cer goto ACCEPT-Cert :DFW-Request CertReq -Submit -f -config "DFWRackCA.rackspace.com\DFWRack-SubCA" %certpath%\%subjectname%.req %certpath%\%subjectname%.cer goto ACCEPT-Cert :LON-Request CertReq -Submit -f -config "LONRackCA.rackspace.com\LONRack-SubCA" %certpath%\%subjectname%.req %certpath%\%subjectname%.cer goto ACCEPT-Cert :IAD-Request CertReq -Submit -f -config "IADRackCA.rackspace.com\IADRack-SubCA" %certpath%\%subjectname%.req %certpath%\%subjectname%.cer goto ACCEPT-Cert :ACCEPT-Cert rem This step needed to import the private key. Also puts the certificate in the local computer personal store. certreq -accept %certpath%\%subjectname%.cer Rem Export the certificate to a PFX file (needed for MOMCertImport utility) certutil -f -p %subjectname% -user -exportPFX %subjectname% %certpath%\%subjectname%.pfx REM Import certificate using MOMCertimport utility momcertimport %certpath%\%subjectname%.pfx /password %subjectname% goto END :USAGE echo. echo GetCert.cmd FQDN_of_machine datacenter_region echo Example: GetCert.cmd servername.customer.com DFW echo Requests, retrieves and installs a client/server authentication certificate from the datacenter region-specific Rackspace Infrastructure Certificate Authority, and gets and installs the Root CA cert so this CA is trusted. echo Valid datacenter regions are: 'DFW', 'IAD', 'HKG', 'LON', 'SAT' echo. :END