Example #1
0
 /**
  * Gets a SSL Connection to MQ.
  *
  * @throws Exception
  */
 private function getSSLConnection()
 {
     $mqcno = array('Version' => MQSERIES_MQCNO_VERSION_4, 'Options' => MQSERIES_MQCNO_STANDARD_BINDING, 'MQCD' => array('Version' => 7, 'ConnectionName' => $this->getConnectionNameAndPort(), 'ChannelName' => $this->channelName, 'TransportType' => MQSERIES_MQXPT_TCP, 'SSLCipherSpec' => 'TLS_RSA_WITH_AES_128_CBC_SHA256', 'CertificateLabel' => $this->certificateLabel), 'MQSCO' => array('KeyRepository' => $this->keyRepository));
     // path to ssl key store - user running code must have read access
     mqseries_connx($this->queueManager, $mqcno, $this->connection, $comp_code, $reason);
     if ($comp_code !== MQSERIES_MQCC_OK) {
         printf("Connx CompCode:%d Reason:%d Text:%s<br>\n", $comp_code, $reason, mqseries_strerror($reason));
         $message = "\nCould not connect to the queue manager.\n";
         $this->log->error($message);
         throw new Exception($message);
     } else {
         $this->log->info("\nSSL Connection successfully open.\n");
     }
 }
Example #2
0
 /**
  * Make a connection to an MQ Server
  * 
  * @param Connectx\Params $connectParams
  * @return boolean
  * @throws \RuntimeException If we have no connection parameters or MQSeries extension is not available
  */
 public function connect($connectParams = null)
 {
     if ($connectParams != null) {
         $this->connectParams = $connectParams;
     }
     if (!$this->mqseriesExtensionLoaded()) {
         throw new ExtensionNotLoadedException("mqseries PHP extension not available");
     }
     if (!$this->connectParams instanceof Connectx\Params) {
         throw new NoConnectionParametersException("No connection parameters available");
     }
     mqseries_connx($this->connectParams->queueManagerName, $this->connectParams->buildConnectionOptions(), $this->connection, $this->completionCode, $this->reason);
     if ($this->completionCode !== MQSERIES_MQCC_OK) {
         $this->logger->log(LogLevel::ERROR, __METHOD__ . "(): " . sprintf("Connx CompCode:%d Reason:%d Text:%s\n", $this->completionCode, $this->reason, mqseries_strerror($this->reason)));
     } else {
         $this->logger->log(LogLevel::INFO, __METHOD__ . "(): CONNECTED TO " . $this->connectParams->queueManagerName . " - " . $this->connectParams->serverConnectionChannel);
         $this->isConnected = true;
     }
     return $this->isConnected;
 }