Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

596 lines
27 KiB

  1. CERT_KEY_PROV_INFO_PROP_ID is needed by boyd's code
  2. typedef struct _CRYPT_KEY_PROV_INFO {
  3. LPWSTR pwszContainerName;
  4. LPWSTR pwszProvName;
  5. DWORD dwProvType;
  6. DWORD dwFlags;
  7. DWORD cProvParam;
  8. PCRYPT_KEY_PROV_PARAM rgProvParam;
  9. DWORD dwKeySpec;
  10. } CRYPT_KEY_PROV_INFO, *PCRYPT_KEY_PROV_INFO;
  11. the above comes from WinCrypt.h.
  12. // This section covers how we interact with the Xenroll and CertServer
  13. // COM objects. It shows a line of action [documenting ALL interaction
  14. // with have with these COM objects] Main action is in nLocEnrl.cpp
  15. // and if any line numbers are given they refer to check in date 4-12-98 v14 in Slim]
  16. hr = spICertGetConfig->GetConfig(0, &ConfigString) ;
  17. Invoke_GetConfig(CComBSTR & {...}, ADMIN_INFO & {...}, IPtr<ICertGetConfig,IID_ICertGetConfig> & {...}) line 2361 + 19 bytes
  18. callXenroll(char * 0x0233ab5c, char * 0x0012dcf0, int 1, TAGCertStates MD_CERT_ENROLL_ENTERING_DATA, ADMIN_INFO & {...}) line 830 + 17 bytes
  19. Finish_NewCertWiz(ADMIN_INFO & {...}, CString & {""}) line 701 + 34 bytes
  20. ==> it will retrieve a ConfigString like "TPOP_DELL\Your Name" <== strange name...
  21. hr = x->put_GenKeyFlags( (DWORD) CRYPT_EXPORTABLE); // in VB use '1' its value see wincrypt.h
  22. &
  23. hr = x->put_ProviderType( pdwType ); // we need PROV_RSA_SCHANNEL but use PROV_RSA_FULL
  24. in the code there is a popup that will ask which to use
  25. &
  26. hr = x->put_HashAlgorithmWStr(L"MD5");
  27. SeeIf_keysExport_or_MD5(ADMIN_INFO & {...}, int 1, IPtr<IEnroll,IID_IEnroll> & {...}) line 2430 + 10 bytes
  28. callXenroll(char * 0x0233ab5c, char * 0x0012dcf0, int 1, TAGCertStates MD_CERT_ENROLL_ENTERING_DATA, ADMIN_INFO & {...}) line 924 + 20 bytes
  29. Finish_NewCertWiz(ADMIN_INFO & {...}, CString & {""}) line 701 + 34 bytes
  30. DWORD dwFlags = 0;
  31. hr = x->get_MyStoreFlags( &dwFlags);
  32. dwFlags &= ~CERT_SYSTEM_STORE_LOCATION_MASK ;
  33. dwFlags |= CERT_SYSTEM_STORE_LOCAL_MACHINE ;
  34. hr = x->put_MyStoreFlags( dwFlags);
  35. ForceCertIntoLocalMachineMyStore(ADMIN_INFO & {...}, IPtr<IEnroll,IID_IEnroll> & {...}) line 230 + 12 bytes
  36. callXenroll(char * 0x0233ab5c, char * 0x0012dcf0, int 1, TAGCertStates MD_CERT_ENROLL_ENTERING_DATA, ADMIN_INFO & {...}) line 975 + 16 bytes
  37. Finish_NewCertWiz(ADMIN_INFO & {...}, CString & {""}) line 701 + 34 bytes
  38. hr = x->createPKCS10WStr(IN BSTR2LPCWSTR(DN), IN BSTR2LPCWSTR(Usage), OUT &PKCS10Blob);
  39. // line: 1178 in nLocEnrl.cpp [as of date 4-12-98 v14 in Slim]
  40. DN="CN=localhost.explorer.TPOP.microsoft.com;O=tjpExploration Air;OU=IIS;C=US;S=Washington;L=Seattle"
  41. Usage="1.3.6.1.5.5.7.3.1,1.3.6.1.4.1.311.10.3.1"
  42. callXenroll(char * 0x0233ab5c, char * 0x0012dcf0, int 1, TAGCertStates MD_CERT_ENROLL_ENTERING_DATA, ADMIN_INFO & {...}) line 1178 + 36 bytes
  43. Finish_NewCertWiz(ADMIN_INFO & {...}, CString & {""}) line 701 + 34 bytes
  44. DoWizardFinish(ADMIN_INFO & {...}) line 282 + 14 bytes
  45. WCHAR* wszContainerName=0;
  46. hr = x->get_ContainerNameWStr( &wszContainerName );
  47. // after this call wszContainerName is: "f6d013e1-d269-11d1-8ac9-00c04fd42c51"
  48. GetContainerName_fromXenroll_storeInMetabase(ADMIN_INFO & {...}, IPtr<IEnroll,IID_IEnroll> & {...}) line 2525 + 12 bytes
  49. callXenroll(char * 0x0233ab5c, char * 0x0012dcf0, int 1, TAGCertStates MD_CERT_ENROLL_ENTERING_DATA, ADMIN_INFO & {...}) line 1184 + 16 bytes
  50. Finish_NewCertWiz(ADMIN_INFO & {...}, CString & {""}) line 701 + 34 bytes
  51. //////////////////////////////////////////////////////////////////
  52. // The following will free the blob and set the byte count
  53. // to Zero for safety (if the upper layer still has a ptr to it).
  54. //////////////////////////////////////////////////////////////////
  55. if(PKCS10Blob.pbData) {
  56. if (bWeAllocated_PKCS10Blob_pbData) // if we allocate it, call XFree
  57. XFree(PKCS10Blob.pbData); // otherwise Xenroll allocated
  58. else // it so call 'freeRequestInfoBlob'
  59. x->freeRequestInfoBlob(PKCS10Blob);
  60. AddBeginEndWrappers(_CRYPTOAPI_BLOB & {...}, int 0, CComBSTR & {...}, unsigned long & 258, ADMIN_INFO & {...}, IPtr<IEnroll,IID_IEnroll> & {...}) line 2908 + 18 bytes
  61. callXenroll(char * 0x0233ab5c, char * 0x0012dcf0, int 1, TAGCertStates MD_CERT_ENROLL_ENTERING_DATA, ADMIN_INFO & {...}) line 1247 + 44 bytes
  62. Finish_NewCertWiz(ADMIN_INFO & {...}, CString & {""}) line 701 + 34 bytes
  63. hr = spICertRequest->Submit(SubmitFlag, bstrPKCS10, Attributes, ConfigString,
  64. OUT &DispositionCode );
  65. //SubmitFlag=258,for binary data in BSTR bstrPKCS10
  66. //Attributes=""
  67. //ConfigString="TPOP_DELL\Your Name" [the string we queried earlier]
  68. //DispositionCode=3 after the successful operation
  69. Send2CA(CComBSTR & {...}, CComBSTR & {...}, unsigned long & 258, CComBSTR & {...}, ADMIN_INFO & {...}, IPtr<ICertRequest,IID_ICertRequest> & {...}) line 3272 + 45 bytes
  70. callXenroll(char * 0x0233ab5c, char * 0x0012dcf0, int 1, TAGCertStates MD_CERT_ENROLL_ENTERING_DATA, ADMIN_INFO & {...}) line 1353 + 38 bytes
  71. Finish_NewCertWiz(ADMIN_INFO & {...}, CString & {""}) line 701 + 34 bytes
  72. hr = spICertRequest->GetCertificate(GetCertFlag, OUT &bstrPKCS7Certificate);
  73. //GetCertFlag=257,because we want a base64 string output
  74. Send2CA(CComBSTR & {...}, CComBSTR & {...}, unsigned long & 258, CComBSTR & {...}, ADMIN_INFO & {...}, IPtr<ICertRequest,IID_ICertRequest> & {...}) line 3355 + 21 bytes
  75. callXenroll(char * 0x0233ab5c, char * 0x0012dcf0, int 1, TAGCertStates MD_CERT_ENROLL_ENTERING_DATA, ADMIN_INFO & {...}) line 1353 + 38 bytes
  76. Finish_NewCertWiz(ADMIN_INFO & {...}, CString & {""}) line 701 + 34 bytes
  77. hr = x->put_RootStoreNameWStr (wszName);
  78. //wszName="CA"
  79. callXenroll(char * 0x0233ab5c, char * 0x0012dcf0, int 1, TAGCertStates MD_CERT_ENROLL_ENTERING_DATA, ADMIN_INFO & {...}) line 1414 + 18 bytes
  80. Finish_NewCertWiz(ADMIN_INFO & {...}, CString & {""}) line 701 + 34 bytes
  81. DoWizardFinish(ADMIN_INFO & {...}) line 282 + 14 bytes
  82. hr = x->acceptPKCS7Blob( &PKCS7Blob );
  83. callXenroll(char * 0x0233ab5c, char * 0x0012dcf0, int 1, TAGCertStates MD_CERT_ENROLL_ENTERING_DATA, ADMIN_INFO & {...}) line 1822 + 15 bytes
  84. Finish_NewCertWiz(ADMIN_INFO & {...}, CString & {""}) line 701 + 34 bytes
  85. DoWizardFinish(ADMIN_INFO & {...}) line 282 + 14 bytes
  86. if ( (PKCS7Blob.cbData == 0)
  87. || ((pCertContext = x->getCertContextFromPKCS7(
  88. IN /*PCRYPT_DATA_BLOB*/ &PKCS7Blob )) == 0))
  89. callXenroll(char * 0x0233ab5c, char * 0x0012dcf0, int 1, TAGCertStates MD_CERT_ENROLL_ENTERING_DATA, ADMIN_INFO & {...}) line 1845 + 21 bytes
  90. Finish_NewCertWiz(ADMIN_INFO & {...}, CString & {""}) line 701 + 34 bytes
  91. DoWizardFinish(ADMIN_INFO & {...}) line 282 + 14 bytes
  92. Now I am trying: http://pkstl1/CertSrv/CertEnroll/krenroll.asp
  93. === its another cert server. We get the same error 0x80093005
  94. ==For this CertServer: http://certsrv/CertSrv/CertEnroll/ceaccept.asp
  95. ==This is what we get back from createPKCS10 when doing a renewal request
  96. ==its pretty big: >4098 chars. When I give this to CertServer I get an error code
  97. ==of 0x80093005
  98. -----BEGIN NEW CERTIFICATE REQUEST-----
  99. MIIMHQYJKoZIhvcNAQcCoIIMDjCCDAoCAQExCzAJBgUrDgMCGgUAMIIGngYJKoZI
  100. hvcNAQcBoIIGjwSCBoswggaHMIIGNQIBADAAMFwwDQYJKoZIhvcNAQEBBQADSwAw
  101. SAJBALSnpRBe3rvyzH7fFaNYhI/bm8jhFX5/Fy5ySGqJoVlVAG1eW2EiGhhITW46
  102. bKSZFvmItHw7s/U5q6NRiMvHpLcCAwEAAaCCBc4wIAYKKwYBBAGCNwIBDjESMBAw
  103. DgYDVR0PAQH/BAQDAgHAMIIBSwYKKwYBBAGCNw0CAjGCATswggE3HoGoAE0AaQBj
  104. AHIAbwBzAG8AZgB0ACAAQgBhAHMAZQAgAEMAcgB5AHAAdABvAGcAcgBhAHAAaABp
  105. AGMAIABQAHIAbwB2AGkAZABlAHIAIAB2ADEALgAwAAAAAAAFAAwBAAAIAAAAAAAA
  106. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAFAAAAFADQABTcoAAgAGQAbABs
  107. AAAADQADAQAADFNSMUEASAAAA4GJAIhSraSWBd0MUKT+LrIzrFo677g6+iRcJlNu
  108. EpqWe/lKpcYBMgqHfTYjHqqLQpYPLgEkQXOlaUB1HJQbQQl0qjNXrYC+NMsqxb4I
  109. vx/bfglMC0tj2niAkpKZxmgE9K+OYIRvHn5DNu0FKSr+fOd9MpEstUFNCqSoyslZ
  110. 3tEnCM9WAAAAAAAAAAAwggRZBgkrBgEEAYI3DQExggRKMIIERjCCA/CgAwIBAgII
  111. Gb0Z4QAABrEwDQYJKoZIhvc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mTg9vWoZmEPs/i8ekztM3lSuE
  158. gQWxpuoenzGCAQYwggECAgEBMIGgMIGTMQswCQYDVQQGEwJVUzELMAkGA1UECBMC
  159. V0ExEDAOBgNVBAcTB1JlZG1vbmQxEzARBgNVBAoTCldpbmRvd3MgTlQxGzAZBgNV
  160. BAsTEkRpc3RyaWJ1dGVkIFN5c3RlbTEzMDEGA1UEAxMqTWljcm9zb2Z0IENlcnRp
  161. ZmljYXRlIFNlcnZlciBUZXN0IEdyb3VwIENBAggZvRnhAAAGsTAJBgUrDgMCGgUA
  162. MA0GCSqGSIb3DQEBAQUABEDMqxiFfAXZ11mtHC2/qRlbB2jtU4bW8EKOWpzOCkig
  163. wsztKwHdqXT0fznLWG790nGfFk9IJ440dAnBSGy4P6J0
  164. -----END NEW CERTIFICATE REQUEST-----
  165. REM Enabling debug
  166. REM
  167. REM If using the NT command shell use:
  168. \\tpophp\public\registry -s -k"HKEY_CURRENT_USER\Software\Microsoft\CertMap\Debug" -n Enabled -v "TRUE"
  169. \\tpophp\public\registry -s -k"HKEY_CURRENT_USER\Software\Microsoft\CertMap\Debug" -n Mode -v "Aging"
  170. REM
  171. REM If you use mks shell use
  172. REM registry -s -k"HKEY_CURRENT_USER\\Software\\Microsoft\\CertMap\\Debug" -n Enabled -v "TRUE"
  173. REM registry -s -k"HKEY_CURRENT_USER\\Software\\Microsoft\\CertMap\\Debug" -n Mode -v "Aging"
  174. [D:/work/test] ./mdutil enum w3svc/info
  175. MajorVersion : [S] (DWORD) 0x4={4}
  176. MinorVersion : [S] (DWORD) 0x0={0}
  177. ServerPlatform : [S] (DWORD) 0x1={1}
  178. Capabilities : [S] (DWORD) 0xfbf={4031} <<===
  179. ServerConfigurationInfo : [S] (DWORD) 0xe={14}
  180. KeyType : [S] (STRING) "IIsWebInfo"
  181. The Capabilities setting will give us the answer to whether this
  182. web server is International or Domestic and allow us to Fix the #Bits
  183. in the key.
  184. After running CertWiz you can expect to see this with MDutil. The lines
  185. with ==> are added by CertWiz
  186. D:\work\test>mdutil enum w3svc\1
  187. ServerSize : [IS] (DWORD) 0x1={Medium}
  188. Win32Error : [S] (DWORD) 0x0={0}
  189. 6269 : [F] (DWORD) 0x1234={4660}
  190. ServerState : [S] (DWORD) 0x4={Stopped}
  191. 5534 : [IS] (DWORD) 0x0={0}
  192. 5532 : [IS] (DWORD) 0x352742d0={891765456}
  193. 5533 : [IS] (DWORD) 0xd={13}
  194. 5531 : [IS] (DWORD) 0xd0ddd00d={-790769651}
  195. ServerComment : [IS] (STRING) "Default Web Site"
  196. KeyType : [S] (STRING) "IIsWebServer"
  197. 5513 : [IS] (STRING) "Tom"
  198. 5507 ==> : [IS] (STRING) "{9D11875D-D144-E285-0F78-C6732D7E1483}"
  199. 5511 ==> : [IS] (STRING) "MY"
  200. 5506 ==> : [IS] (BINARY) 0xa1 32 6e 8d 3e 4c ea 5c c6 c2 d0 18 65 17 d7 de 3e a3 ed 53
  201. ServerBindings : [IS] (MULTISZ) ":80:"
  202. SecureBindings : [IS] (MULTISZ) ":443:"
  203. SysAllocStringLen can have embedded nulls use:
  204. BSTR SysAllocStringLen( OLECHAR FAR* pch, unsigned int cch )
  205. This version of MsgBox uses the string resource with the ID [nIDPrompt] to
  206. display a message in the message box. The associated Help page is found
  207. through the value of nIDHelp. If the default value of nIDHelp is
  208. used (� 1), the string resource ID, nIDPrompt, is used for the Help context.
  209. For more information about defining Help contexts, see the article Help
  210. Topics in Visual C++ Programmer's Guide and Technical Note 28.
  211. This version of MsgBox uses the string resource with the ID [nIDPrompt] to
  212. // when doing key ring import we ran into trouble when we tried to do a ViewCert
  213. // and passed in the cert pointer: here is the code from NKMuxPg.cpp near ln 1258
  214. if (pCertContext!=0)
  215. {
  216. if (YesNoMsgBox(
  217. Easy::Load(szResourceStr,
  218. IDS_WOULD_YOU_LIKE_TO_VIEW_THE_CERTIFICATE_THAT_YOU_JUST_IMPORTED
  219. // "Would you like to view the Certificate that you just imported?"
  220. )))
  221. {
  222. ViewACert( pCertContext );
  223. // after hitting break in the debugger we get the following stack dump
  224. NTDLL! 77f98bb3()
  225. MSAFD! 77514dd7()
  226. WS2_32! 7756357b()
  227. WSOCK32! 775811d7()
  228. // as we call FinCertImport::OnWizardFinish() that will take the filename
  229. // c:/tmp/newcert318.cer and process it in Xenroll to finalize the OOB
  230. // this is the stack
  231. CFinCertImport::OnWizardFinish() line 212
  232. MFC42! 5f46f278()
  233. MFC42! 5f40230b()
  234. MFC42! 5f402294()
  235. MFC42! 5f40221f()
  236. AfxWndProcDllStatic(HWND__ * 0x000c0a0c, unsigned int 78, unsigned int 0, long 1237948) line 57 + 21 bytes
  237. USER32! 77e753d0()
  238. USER32! 77e762d5()
  239. COMCTL32! 779f709a()
  240. COMCTL32! 77a035a6()
  241. COMCTL32! 77a30fd1()
  242. COMCTL32! 77a31e74()
  243. USER32! 77e87983()
  244. USER32! 77e8be30()
  245. USER32! 77e75bc1()
  246. MFC42! 5f402783()
  247. MFC42! 5f402322()
  248. MFC42! 5f402294()
  249. MFC42! 5f40221f()
  250. AfxWndProcDllStatic(HWND__ * 0x00350812, unsigned int 273, unsigned int 12325, long 3213652) line 57 + 21 bytes
  251. USER32! 77e753d0()
  252. USER32! 77e762d5()
  253. USER32! 77e8f3d1()
  254. USER32! 77e91486()
  255. USER32! 77e7387f()
  256. USER32! 77e79704()
  257. USER32! 77e8ddab()
  258. // when we run xenroll to finish an OOB and we get a error this is typically
  259. // what the call stack will be
  260. DisplayError_ErrorReturn(long -2146885628, ADMIN_INFO & {...}, char * 0x00c43854) line 3796
  261. DisplayError_ErrorReturn(long -2146885628, ADMIN_INFO & {...}, unsigned int 4068, TAGCertStates MD_CERT_ENROLL_RECVED_ERR_FROM_ENROLL) line 3879 + 17 bytes
  262. callXenroll(char * 0x5f4c86bc, char * 0x0012e0f4, int 4, TAGCertStates MD_CERT_ENROLL_PROCESSING_PKCS7_OUTOFBAND, ADMIN_INFO & {...}) line 1652 + 23 bytes
  263. Finish_FinishOOBCertWiz(ADMIN_INFO & {...}, CString & {""}) line 519 + 34 bytes
  264. CFinCertImport::OnWizardFinish() line 263 + 26 bytes
  265. MFC42! 5f46f278()
  266. MFC42! 5f40230b()
  267. MFC42! 5f402294()
  268. MFC42! 5f40221f()
  269. AfxWndProcDllStatic(HWND__ * 0x000c0a24, unsigned int 78, unsigned int 0, long 1238152) line 57 + 21 bytes
  270. USER32! 77e753d0()
  271. USER32! 77e762d5()
  272. COMCTL32! 779f709a()
  273. COMCTL32! 77a035a6()
  274. COMCTL32! 77a30fd1()
  275. COMCTL32! 77a31e74()
  276. USER32! 77e87983()
  277. USER32! 77e8be30()
  278. The second form of the function uses the string resource with the ID nIDPrompt to display a message in the message box. The associated Help page is found through the value of nIDHelp. If the default value of nIDHelp is used (� 1), the string resource ID, nIDPrompt, is used for the Help context. For more information about defining Help contexts, see the article Help Topics in Visual C++ Programmer's Guide and Technical Note 28.
  279. 00125DCC 30 82 04 2D 30 82 03 D7 A0 0�.-0�.נ
  280. 00125DD5 03 02 01 02 02 08 06 A6 C6 .......��
  281. 00125DDE 5C 00 00 05 BD 30 0D 06 09 \...�0..
  282. 00125DE7 2A 86 48 86 F7 0D 01 01 04 *�H��....
  283. 00125DF0 05 00 30 81 93 31 0B 30 09 ..0.�1.0
  284. 00125DF9 06 03 55 04 06 13 02 55 53 ..U....US
  285. 00125E02 31 0B 30 09 06 03 55 04 08 1.0 ..U..
  286. 00125E0B 13 02 57 41 31 10 30 0E 06 ..WA1.0..
  287. 00125E14 03 55 04 07 13 07 52 65 64 .U....Red
  288. 00125E1D 6D 6F 6E 64 31 13 30 11 06 mond1.0..
  289. 00125E26 03 55 04 0A 13 0A 57 69 6E .U....Win
  290. 00125E2F 64 6F 77 73 20 4E 54 31 1B dows NT1.
  291. 00125E38 30 19 06 03 55 04 0B 13 12 0...U....
  292. 00125E41 44 69 73 74 72 69 62 75 74 Distribut
  293. 00125E4A 65 64 20 53 79 73 74 65 6D ed System
  294. 00125E53 31 33 30 31 06 03 55 04 03 1301..U..
  295. 00125E5C 13 2A 4D 69 63 72 6F 73 6F .*Microso
  296. 00125E65 66 74 20 43 65 72 74 69 66 ft Certif
  297. 00125E6E 69 63 61 74 65 20 53 65 72 icate Ser
  298. 00125E77 76 65 72 20 54 65 73 74 20 ver Test
  299. 00125E80 47 72 6F 75 70 20 43 41 30 Group CA0
  300. "CertificateAuthority.Request" is the request object that we use in VB
  301. 0012D5E8 F0 F3 AF 98 24 55 D0 11 88 12 00
  302. 0012D5F3 A0 C9 03 B8 3C
  303. Using this code:
  304. if (Util::PeekBool(++cStepCnt > 0) // a failure here will have cnt=1
  305. && (hr=E_FAIL) // trick so that we get a nice error code if the bstr extract fails
  306. && bstr
  307. && Util::PeekBool(++cStepCnt > 0) // a failure here will have cnt=2, etc...
  308. && SUCCEEDED( hr=convertPKCS7_BSTR2Blob( IN /*CComBSTR& */ bstrPKCS7Contents,
  309. OUT /*CRYPT_DATA_BLOB&*/ PKCS7Blob) )
  310. && Util::PeekBool(++cStepCnt > 0)
  311. && SUCCEEDED( hr = x->acceptPKCS7Blob( IN /*PCRYPT_DATA_BLOB*/ &PKCS7Blob))
  312. I am getting a HR of 0x80093009 <-- a failure from the acceptPKCS7Blob
  313. any ideas? I believe that I imported and decoded
  314. it properly, I will show the cert below also
  315. as an attachment.
  316. >> I think that the code is sound but the Cert Server gave
  317. >> me a bad cert file. BECAUSE if I click on the pkcs7.cer
  318. >> file under NT's fileExplorer it says "Invalid Security Cert File"
  319. PKCS7Blob.cbData = 1748 The PKCS7Blob.pbData = 0x00128864
  320. Here is the first part of my PKCS7Blob:
  321. 00128864 50 44 FC 77 D8 D1 18 00 00 00 14 PD�w��.....
  322. 0012886F 00 E0 D1 18 00 E8 88 12 00 2B E8 .��..��..+�
  323. 0012887A FB 77 81 E8 FB 77 48 05 14 00 00 �w.��wH....
  324. 00128885 00 14 00 E0 D1 18 00 50 10 4B 00 ...��..P.K.
  325. 00128890 38 00 00 00 48 88 12 00 C0 D6 18 8...H�..��.
  326. 0012889B 00 3C 89 12 00 50 44 FC 77 68 2D .<�..PD�wh-
  327. 001288A6 F9 77 FF FF FF FF 4C 89 12 00 37 �w����L�..7
  328. 001288B1 FF FA 77 00 00 14 00 61 00 00 50 ��w....a..P
  329. 001288BC 01 D6 18 00 00 00 14 00 70 F3 14 .�......p�.
  330. 001288C7 00 00 00 00 00 70 89 12 00 00 00 .....p�....
  331. 001288D2 14 00 AD 00 FB 77 80 F3 14 00 F8 ..�.�w��..�
  332. 0018CAD0 30 82 01 74 30 82 01 22 02 01 00 0�.t0�."...
  333. 0018CADB 30 81 85 31 28 30 26 06 03 55 04 0.�1(0&..U.
  334. 0018CAE6 03 13 1F 77 77 77 2E 32 54 50 4F ...www.2TPO
  335. 0018CAF1 50 44 45 4C 4C 2E 64 6E 73 2E 6D PDELL.dns.m
  336. 0018CAFC 69 63 72 6F 73 6F 66 74 2E 63 6F icrosoft.co
  337. 0018CB07 6D 31 12 30 10 06 03 55 04 0A 13 m1.0...U...
  338. 0018CB12 09 4D 69 63 72 6F 73 6F 66 74 31 Microsoft1
  339. 0018CB1D 11 30 0F 06 03 55 04 0B 13 08 49 .0...U....I
  340. 0018CB28 49 53 44 65 76 32 32 31 0B 30 09 ISDev221.0
  341. 0018CB33 06 03 55 04 06 13 02 55 53 31 13 ..U....US1.
  342. 0018CB3E 30 11 06 03 55 04 08 13 0A 57 61 0...U....Wa
  343. 0018CB49 73 68 69 6E 67 74 6F 6E 31 10 30 shington1.0
  344. 0018CB54 0E 06 03 55 04 07 13 07 52 65 64 ...U....Red
  345. 0018CB5F 6D 6F 6E 64 30 5C 30 0D 06 09 2A mond0\0.. *
  346. 0018CB6A 86 48 86 F7 0D 01 01 01 05 00 03 �H��.......
  347. 0018CB75 4B 00 30 48 02 41 00 DF 81 A8 A9 K.0H.A.�.��
  348. 0018CB80 7A 1A E6 0F A9 66 49 6E 6A 65 A1 z.�.�fInje�
  349. 0018CB8B E2 2E A5 8E 89 D5 4D E0 91 3D 6C �.����M��=l
  350. 0018CB96 EE 0B E7 52 43 9E CD 2C 15 E7 48 �.�RC��,.�H
  351. 0018CBA1 85 64 A5 2E BD 14 A7 12 D4 56 90 �d�.�.�.�V.
  352. 0018CBAC 40 98 A9 BB 47 09 77 F2 96 FB 33 @���G w���3
  353. 0018CBB7 11 40 B0 A2 B1 02 03 01 00 01 A0 .@���.....�
  354. 0018CBC2 37 30 35 06 0A 2B 06 01 04 01 82 705..+....�
  355. 0018CBCD 37 02 01 0E 31 27 30 25 30 0E 06 7...1'0%0..
  356. ========================================================================
  357. ActiveX CertWizard Control DLL : CERTMAP
  358. ========================================================================
  359. 1. Enabling Debugging
  360. /////////////////////////////////////////////////////////////////////
  361. //
  362. // If using the NT command shell use:
  363. // registry -s -k"HKEY_CURRENT_USER\Software\Microsoft\CertMap\Debug" -n Enabled -v "TRUE"
  364. //
  365. //
  366. // All you MKS shell users can enable it by doing:
  367. // registry -s -k"HKEY_CURRENT_USER\\Software\\Microsoft\\CertMap\\Debug" -n Enabled -v "TRUE"
  368. //
  369. // [if you want the aging feature that rescans every 12 calls, then
  370. // you also need to set MODE=Aging]
  371. //
  372. // If using the NT command shell use:
  373. // registry -s -k"HKEY_CURRENT_USER\Software\Microsoft\CertMap\Debug" -n Mode -v "Aging"
  374. // All you MKS shell users can enable it by doing:
  375. // registry -s -k"HKEY_CURRENT_USER\\Software\\Microsoft\\CertMap\\Debug"-n Mode -v "Aging"
  376. //
  377. // Similarly for you MKS'sh-ers you can use the following command to test if its enabled:
  378. // registry -p -k"HKEY_CURRENT_USER\\Software\\Microsoft\\CertMap\\Debug"
  379. // If it says:
  380. //
  381. // HKEY_CURRENT_USER\Software\Microsoft\CertMap\Debug Enabled "TRUE"
  382. //
  383. // Its enabled!
  384. /////////////////////////////////////////////////////////////////////
  385. //
  386. //
  387. // Similarly for you MKS'sh-ers you can use the following command to test if its enabled:
  388. // registry -p -k"HKEY_CURRENT_USER\\Software\\Microsoft\\CertMap\\Debug"
  389. // If it says:
  390. //
  391. // HKEY_CURRENT_USER\Software\Microsoft\CertMap\Debug Enabled "TRUE"
  392. If you dont have MKS just use the command regEdt32 to do it.
  393. 2. Testing the MS Cert Server Online CA
  394. You need to install at least a stub in the registry. I do it
  395. with MKS ksh doing the following operations: We need a Reg Key
  396. named "${CA}\\${MS}" to exist under HKEY_LOCAL_MACHINE. The following
  397. code will just create it and install a {name=Enabled value=True} setting
  398. MS="Microsoft Certificate Server"
  399. CA="Software\\Microsoft\\CertMap\\Parameters\\Certificate Authorities"
  400. registry -s -k"HKEY_LOCAL_MACHINE\\${CA}\\${MS}" -n Enabled -v True
  401. If you dont have MKS just use the command regEdt32 to do it.
  402. 3. What if CertServer is suspected of having problems or is not running?
  403. Here is what we do: ReInstall it by:
  404. [C:/WINNT50/system32] sysocmgr -i:certmast.inf -n
  405. Then check if it works by running -- this just prints out the config info
  406. [C:/WINNT50/system32] ./certutil
  407. Entry 0:
  408. Name: `Your Name'
  409. OrgUnit: `Your Unit'
  410. Organization: `Your Organization'
  411. Locality: `Your Locality'
  412. State: `Your State'
  413. Country: `US'
  414. Config: `TPOP_DELL\Your Name'
  415. SignatureCertificate: `TPOP_DELL_Your Name.crt'
  416. Description: `Your Description.'
  417. Server: `TPOP_DELL'
  418. Authority: `Your Name'
  419. For debugging you can fire up a testing tool that starts up a shell
  420. window so that you can watch CertServer requests/tasks while it works:
  421. [C:/WINNT50/system32] start certsrv -z
  422. Note that if you want to run the above command YOU MUST MAKE SURE THAT
  423. CERT SERVER IS STOPED FIRST SINCE IT WILL START IT AS A SERVICE AND
  424. YOU CAN ONLY HAVE 1 CERT SERV SERVICE. Use the following to do it:
  425. [C:/WINNT50/system32] net stop certsvc
  426. You might notice that we say certSVC not certSVR as in 'start certsrv -z'
  427. ========================================================================
  428. ActiveX Control DLL : CERTMAP
  429. ========================================================================
  430. ControlWizard has created this project for your CERTMAP OLE Control DLL,
  431. which contains 1 control.
  432. This skeleton project not only demonstrates the basics of writing an OLE
  433. Control, but is also a starting point for writing the specific features
  434. of your control.
  435. This file contains a summary of what you will find in each of the files
  436. that make up your CERTMAP OLE Control DLL.
  437. certmap.mak
  438. The Visual C++ project makefile for building your OLE Control.
  439. certmap.h
  440. This is the main include file for the OLE Control DLL. It
  441. includes other project-specific includes such as resource.h.
  442. certmap.cpp
  443. This is the main source file that contains code for DLL initialization,
  444. termination and other bookkeeping.
  445. certmap.rc
  446. This is a listing of the Microsoft Windows resources that the project
  447. uses. This file can be directly edited with the Visual C++ resource
  448. editor.
  449. certmap.def
  450. This file contains information about the OLE Control DLL that
  451. must be provided to run with Microsoft Windows.
  452. certmap.clw
  453. This file contains information used by ClassWizard to edit existing
  454. classes or add new classes. ClassWizard also uses this file to store
  455. information needed to generate and edit message maps and dialog data
  456. maps and to generate prototype member functions.
  457. certmap.odl
  458. This file contains the Object Description Language source code for the
  459. type library of your control.
  460. /////////////////////////////////////////////////////////////////////////////
  461. Certmap control:
  462. CertCtl.h
  463. This file contains the declaration of the CCertmapCtrl C++ class.
  464. CertCtl.cpp
  465. This file contains the implementation of the CCertmapCtrl C++ class.
  466. CertPpg.h
  467. This file contains the declaration of the CCertmapPropPage C++ class.
  468. CertPpg.cpp
  469. This file contains the implementation of the CCertmapPropPage C++ class.
  470. CertCtl.bmp
  471. This file contains a bitmap that a container will use to represent the
  472. CCertmapCtrl control when it appears on a tool palette. This bitmap
  473. is included by the main resource file certmap.rc.
  474. /////////////////////////////////////////////////////////////////////////////
  475. Other standard files:
  476. stdafx.h, stdafx.cpp
  477. These files are used to build a precompiled header (PCH) file
  478. named stdafx.pch and a precompiled types (PCT) file named stdafx.obj.
  479. resource.h
  480. This is the standard header file, which defines new resource IDs.
  481. The Visual C++ resource editor reads and updates this file.
  482. /////////////////////////////////////////////////////////////////////////////
  483. Other notes:
  484. ControlWizard uses "TODO:" to indicate parts of the source code you
  485. should add to or customize.
  486. /////////////////////////////////////////////////////////////////////////////