<div class="content"><p>The ExportToBlob method exports the <a href="1243ba70-74ca-44f9-be0b-dfd6697010b4#gt_7a0f4b71-23ba-434f-b781-28053ed64879" data-linktype="relative-path">certificate</a> referenced at <i>InstanceName</i>
to a memory buffer.</p><dl>
<dd>
<div><pre> [id(19)] HRESULT ExportToBlob(
     [in] BSTR InstanceName,
     [in] BSTR Password, 
     [in] VARIANT_BOOL bPrivateKey,
     [in] VARIANT_BOOL bCertChain,
     [in,out] DWORD *pcbSize,
     [in,out,string] CHAR **pBlobBinary
 );
</pre></div>
</dd></dl><p><b>InstanceName: </b>A string that specifies a web <a href="1243ba70-74ca-44f9-be0b-dfd6697010b4#gt_1623705d-a7a0-4e46-9a66-66e9ee63d961" data-linktype="relative-path">server instance</a>.</p><p><b>Password: </b>A password used to <a href="1243ba70-74ca-44f9-be0b-dfd6697010b4#gt_8312d817-fdc5-4a49-8894-729b7b9e0ce5" data-linktype="relative-path">encrypt</a> the exported
certificate data.</p><p><b>bPrivateKey: </b>If set to VARIANT_TRUE, indicates
that the <a href="1243ba70-74ca-44f9-be0b-dfd6697010b4#gt_6fca10f4-e829-42ab-ad40-1566585060ca" data-linktype="relative-path">private key</a> of
the certificate is to be exported.</p><p><b>bCertChain: </b> If set to VARIANT_TRUE, indicates
that the <a href="1243ba70-74ca-44f9-be0b-dfd6697010b4#gt_4c9526d0-366f-45c3-928f-6097a1eb5533" data-linktype="relative-path">certificate chain</a>
of the certificate referenced by <i>InstanceName</i> is to be exported.</p><p><b>pcbSize: </b>If the method succeeds, returns the
number of valid bytes returned in <i>pBlobBinary</i>.</p><p><b>pBlobBinary: </b>If the method succeeds, returns a
pointer to a memory buffer containing the exported certificate data. The buffer
contains a null-terminated, <a href="1243ba70-74ca-44f9-be0b-dfd6697010b4#gt_179b9392-9019-45a3-880b-26f6890522b7" data-linktype="relative-path">base64</a>-encoded
array of bytes. The client MUST free the pointer returned in <i>pBlobBinary</i>
using the appropriate memory allocator as specified for the DCOM
implementation.<a id="Appendix_A_Target_43"></a><a aria-label="Product behavior note 43" href="88fd1df0-e63e-41ca-9bf3-bedcab57cd86#Appendix_A_43" data-linktype="relative-path">&lt;43&gt;</a></p><p><b>Return Values: </b>A signed 32-bit value that
indicates return status. If the method returns a negative value, it failed. If
the 12-bit facility code (bits 16–27) is set to 0x007, the value contains a
Win32 error code in the lower 16 bits. Zero or positive values indicate
success, with the lower 16 bits in positive nonzero values containing warnings
or flags defined in the method implementation. For more information about Win32
error codes and <a href="../ms-dtyp/a9046ed2-bfb2-4d56-a719-2824afce59ac" data-linktype="relative-path">HRESULT</a>
values, see <a href="../ms-erref/1bc92ddf-b79e-413c-bbaa-99a5281a6c90" data-linktype="relative-path">[MS-ERREF]</a>.</p><dl>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Return value/code</p>
   </th>
   <th>
   <p>Description</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>
  <p>0x00000000</p>
  <p>S_OK</p>
  </td>
  <td>
  <p>The call was successful.</p>
  </td>
 </tr><tr>
  <td>
  <p>0x80070057</p>
  <p>E_INVALIDARG</p>
  </td>
  <td>
  <p>One or more arguments are invalid.</p>
  </td>
 </tr><tr>
  <td>
  <p>0x000006cf</p>
  <p>RPC_S_STRING_TOO_LONG</p>
  </td>
  <td>
  <p>The string is too long.</p>
  </td>
 </tr><tr>
  <td>
  <p>0x800CC801</p>
  <p>MD_ERROR_DATA_NOT_FOUND</p>
  </td>
  <td>
  <p>The specified metadata was not found.</p>
  </td>
 </tr><tr>
  <td>
  <p>0x80092004</p>
  <p>CRYPT_E_NOT_FOUND</p>
  </td>
  <td>
  <p>Cannot find object or property.</p>
  </td>
 </tr><tr>
  <td>
  <p>0x80090349</p>
  <p>SEC_E_CERT_WRONG_USAGE</p>
  </td>
  <td>
  <p>The certificate is not valid for the requested usage.</p>
  </td>
 </tr></tbody></table>
</dd></dl><p>The <b>opnum</b> field value for this method is 25.</p><p>When processing this call, the server MUST do the following:</p><ul><li><p><span><span> 
</span></span>If <i>InstanceName</i> or <i>Password</i> are empty strings,
return E_INVALIDARG.</p>
</li><li><p><span><span> 
</span></span>If <i>InstanceName</i> or <i>Password</i> contains more than 260
characters, return RPC_STRING_TOO_LONG.</p>
</li><li><p><span><span> 
</span></span>Attempt to retrieve the certificate referenced at the specified <i>InstanceName</i>.
If the certificate cannot be retrieved on the target system, if no certificate
is referenced at the specified <i>InstanceName</i>, or if the certificate is
not suitable for use by the server for <a href="1243ba70-74ca-44f9-be0b-dfd6697010b4#gt_d7ef66a9-f154-4d88-bda9-98bdf7235352" data-linktype="relative-path">SSL</a>, return an error.</p>
</li><li><p><span><span> 
</span></span>Attempt to export the certificate using the specified password, <i>Password</i>.
If <i>bPrivateKey</i> is 1 or VARIANT_TRUE, include the private key in the
exported data. If <i>bCertChain</i> is 1 or VARIANT_TRUE, include the
certificate&#39;s associated certificate chain in the exported data.<a id="Appendix_A_Target_44"></a><a aria-label="Product behavior note 44" href="88fd1df0-e63e-41ca-9bf3-bedcab57cd86#Appendix_A_44" data-linktype="relative-path">&lt;44&gt;</a></p>
</li><li><p><span><span> 
</span></span>If the requested data was exported successfully, base64 encode
the exported data; allocate a buffer to return to the client in <i>pBlobBinary</i>;
copy the data to the buffer pointed to by <i>pBlobBinary</i>; and return the
number of bytes in the exported and encoded blob in <i>pcbSize</i>; otherwise,
return an error.<a id="Appendix_A_Target_45"></a><a aria-label="Product behavior note 45" href="88fd1df0-e63e-41ca-9bf3-bedcab57cd86#Appendix_A_45" data-linktype="relative-path">&lt;45&gt;</a></p>
</li></ul></div>