Usage guide

The following code segment demonstrates how to share certificates among a group of queue managers:

/*SIMPLE MQePublicRegistry shareCertificate FRAGMENT */
	MQePublicRegistryHndl pubreg;
	MQePrivateRegistryHndl preg;
	MQERETURN rc;
	MQeExceptBlock exceptBlock;
	MQeStringHndl hEntityName;
	MQeFieldsHndl hCert;
	MQEINT32 i;
 
	/*instantiate and activate PublicReg */
	rc = mqePublicRegistry_new(&exceptBlock, &pubreg);
	rc = mqePublicRegistry_activate(pubreg, &exceptBlock, 
                                   MQeString("MQeNode_PublicRegistry"),
												 MQeString(".\\"));
	/* auto-register Bruce1,Bruce2...Bruce8 */
	/* ... note that the mini-certificate issuance service must */
	/* have been configured to allow the auto-registration    */
	for (i = 1; i < 9; i++)
	{
		rc = MQeString_new(&exceptBlock, 
								 	&hEntityName, strcat("Bruce" + itoa(i)));
		rc = mqePrivateRegistry_new(&exceptBlock, &preg);
		/* activate() will initiate auto-registration */
		rc = mqePrivateRegistry_activate(
			preg,
			&exceptBlock,
			hEntityName,
			MQeString(".\\MQeNode_PrivateRegistry"),
		 	MQeString("12345678"),
			MQeString("It_is_a_secret"),
			MQeString("12345678"),
			MQeString("9.20.X.YYY:8082")
		     );
		/* save MiniCert from PrivReg in PubReg*/
		rc = mqePrivateRegistry_getCertificate(preg, &exceptBlock, 
																&hCert, hEntityName);
		rc = mqePublicRegistry_putCertificate(pubreg, &exceptBlock, 
																hEntityName, hCert);
		/* before share of MiniCert */
		rc = mqePublicRegistry_shareCertificate(pubreg,&exceptBlock, 
																hEntityName, hCert, 
																MQeString("9.20.X.YYY:8082"));
		rc = mqePrivateRegistry_close(preg, &exceptBlock);
		(void)mqePrivateRegistry_free(preg, NULL);
		(void)mqeString_free(hEntityName, NULL);
		(void)mqeFields_free(hCert, NULL);
	}
	rc = mqePublicRegistry_close(pubreg, &exceptBlock);
	(void)mqePublicRegistry_close(pubreg, NULL);

Notes:

  1. It is not possible to activate a registry instance more than once, hence the example above demonstrates the recommended practice of accessing a private registry by creating a new instance of MQePrivateRegistry, activating the instance, performing the required operations and closing the instance.

  2. If you want to share certificates using a public registry on the home-server, the public registry must be called MQeNode_PublicRegistry.


© IBM Corporation 2000, 2003. All Rights Reserved