The MQRegisterCertificate function registers an internal or external certificate in the directory service. Registering a certificate stores the public part of the certificate in the directory service under the applicable user object.
HRESULT APIENTRY MQRegisterCertificate( DWORD dwFlags, PVOID lpCertBuffer, DWORD dwCertBufferLength );
[in] Specifies when the certificate is registered. Specify one of the following:
Registers an internal or external certificate each time MQRegisterCertificate is called.
For internal certificates (lpCertBuffer = NULL), a new certificate is created and registered.
For external certificates, this option must be set.
Registers an internal certificate only when none exist. This option cannot be used when registering external certificates.
If an internal certificate is found, the certificate is not registered. In this case, the call succeeds and the MQ_INFORMATION_INTERNAL_USER_CERT_EXIST information code is returned.
Checking for an existing certificate is done locally, without querying the directory service.
[in] Pointer to the buffer that contains the certificate blob of an external certificate, or NULL if registering an internal certificate. External certificates must be in ASN.1 DER encoded format.
[in] The length of the certificate buffer. For internal certificates, specify 0.
Message Queuing cannot create a certificate store for its internal certificate. This error is returned only when you do not have permission to manipulate your own profile.
Message Queuing cannot open the certificate store for its internal certificate. This error is only returned only when you do not have permission to manipulate your own profile.
User is not a domain user. You must be a domain user to be able to register a certificate. This function is not supported for local user accounts.
The internal or external certificate specified is already registered in Active Directory Domain Services (AD DS) for the user.
A supplied parameter is not set to a valid value. For example, dwCertBufferLength is set to 0 and lpCertBuffer points to a buffer containing an external certificate.
A computer operating in workgroup attempted to register a certificate in the directory service.
An internal certificate already exists for the user. This information code does not indicate an error condition. It is returned when dwFlags is set to MQ_REGISTER_IF_NOT_EXIST.
Message Queuing can only register external certificates placed in the Microsoft® Internet Explorer personal certificate store. To obtain an external certificate, contact a trusted certification authority. For example, request a class 1 certificate from VeriSign Commercial Software Publishers using Microsoft Internet Explorer. If Internet Explorer is used to obtain the certificate, the certificate is automatically placed in the Microsoft Internet Explorer personal certificate store.
Certificates can also be registered in the Message Queuing Properties dialog box, which can be opened from Computer Management in MSMQ 3.0 (or from the applicable Control Panel applet in MSMQ 1.0 and MSMQ 2.0). To register a certificate in MSMQ 3.0, go to the User Certificate page, and then under User certificates, click Register.
Equivalent COM Method
When using COM components, you can register certificates by calling MSMQApplication.RegisterCertificate.
The following code examples are included in Using Message Queuing.
|For an example of||See|
Sending a message with an internal certificate attached
Sending a message with an external certificate attached
Reading messages to see if authentication was requested by the sending application
Windows NT/2000/XP: Included in Windows 2000 and later.
Windows 95/98/Me: Unsupported.
Header: Declared in Mq.h.
Library: Use Mqrt.lib.