To dowload the CA certificate from CorpCA and save it as CAcertificate.cer, use the following command line:
certutil -f -config "cahost.contoso.comCorpCA" -ca.cert CAcertificate.cer
To place CACertificate.cer in the Local Computer Trusted Root Certificate Authorities store, use the following command line:
certutil -addstore Root CAcertificate.cer
More information on certutil usage can be found at http://technet2.microsoft.com/windowsserver/en/library/a3d5dbb9-1bf6-42da-a13b-2b220b11b6fe103...
Obtaining and Installing a Client Certificate
Now let's get a client certificate which will be presented when attempting to authenticate. There are a few steps to do this via command line.
Open Notepad and make a new file named "RequestConfig.inf" Paste the following text into the file:
(If your CA is stand-alone)
[NewRequest]
Subject="CN=<Machine FQDN>"
Exportable=TRUE
KeyLength=1024
KeySpec=1
KeyUsage=0xf0
MachineKeySet=TRUE
[EnhancedKeyUsageExtension]
OID=1.3.6.1.5.5.7.3.1
OID=1.3.6.1.5.5.7.3.2(If your CA is enterprise and has implemented a template call OpsMgrCertificate as detailed in the above-linked guide)
[NewRequest]
Subject="CN=<Machine FQDN>"
KeySpec=1
KeyUsage=0xf0
MachineKeySet=TRUE
[RequestAttributes]
CertificateTemplate="OpsMgrCertificate"
2. Convert the INF into a binary REQ file.
Run the following command line to create BinaryRequest.req from RequestConfig.inf:
certreq -new -f RequestConfig.inf BinaryRequest.req
More information on the syntax of the INF file, as well as detailed usage information for CertReq, can be found at http://technet2.microsoft.com/windowsserver/en/library/008acdeb-0650-4063-a9a2-1258b3229d4f103...
3. Submit the binary request to the CA and retrieve the resulting certificate.
Run the following command line to submit BinaryRequest.req to CorpCA :
certreq -submit -f -config "cahost.contoso.comCorpCA" BinaryRequest.req
If your CA is set up to auto-approve certificate requests, you will immediately be prompted to save the resulting certificate. If you anticipate this to be the case, you can optionally skip the Save dialog by specifying the filename you want to save to (for example NewCertificate.cer) as an extra argument to the above command line.
Otherwise the RequestId of your request will be printed to the console. An admin at the CA must then choose to issue the certificate. Once the cert is issued, you can retrieve it and save the certificate as NewCertificate.cer by running the following command line:
certreq -retrieve -f -config "cahost.contoso.comCorpCA" <RequestId> NewCertificate.cer
4. Install the certificate
To install NewCertificate.cer into the Local Computer Personal store, run the following command line:
certreq -accept NewCertificate.cer
And there you have it! You should now have the needed CA certificate and client certificate, both installed in the proper places. From here run MOMCertImport.exe (either double click it to use the GUI or run with the /SubjectName command line flag) to have Ops Mgr consume your new certificate and being authenticating with it. These steps need to be followed on both the Management Server and the Gateway.
Below is a simple batch script GetCert.cmd which ties together all of the steps above. This script is suitable for stand-alone CorpCA, set to auto-approve all requests.
if {%1} equ {/?} goto USAGE
if {%1} equ {-?} goto USAGE
if {%1} equ {?} goto USAGE
if {%1} equ {} goto USAGE
set subjectname=%1
set certpath=%systemdrive%OMCertificates
mkdir %certpath%
rem Get the CA's cert
certutil -f -config cahost.contoso.comCorpCA -ca.cert %certpath%CACertificate.cer
rem Move the CA's cert to the "Trusted Root Authorities" store
certutil -f -addstore Root %certpath%CACertificate.cer
rem Create an INF request file with the specified subjectname
del %certpath%RequestConfig.inf
echo [NewRequest] > %certpath%RequestConfig.inf
echo Subject="CN=%subjectname%" >> %certpath%RequestConfig.inf
echo Exportable=TRUE >> %certpath%RequestConfig.inf
echo KeyLength=1024 >> %certpath%RequestConfig.inf
echo KeySpec=1 >> %certpath%RequestConfig.inf
echo KeyUsage=0xf0 >> %certpath%RequestConfig.inf
echo MachineKeySet=TRUE >> %certpath%RequestConfig.inf
echo [EnhancedKeyUsageExtension] >> %certpath%RequestConfig.inf
echo OID=1.3.6.1.5.5.7.3.1 >> %certpath%RequestConfig.inf
echo OID=1.3.6.1.5.5.7.3.2 >> %certpath%RequestConfig.inf
rem Create a binary request file from the INF
del %certpath%BinaryRequest.req
CertReq -New -f %certpath%RequestConfig.inf %certpath%BinaryRequest.req
rem Submit the request to our CA and save the certificate
CertReq -Submit -f -config "cahost.contoso.comCorpCA" %certpath%BinaryRequest.req %certpath%NewCertificate.cer
rem This step needed to import the private key. Also puts the certificate in the local computer personal store.
certreq -accept %certpath%NewCertificate.cer
goto END
:USAGE
echo.
echo GetCert.cmd FQDN_of_machine
echo Example: GetCert.cmd Computer01.Contoso.com
echo Gets and installs a cert from CA cahost.contoso.com (CorpCA) appropriate for OMv3, and also gets and installs CA cert so this CA is trusted.
echo.
:END
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.