function hosting_ssl_save_key in Hosting 7.4
Same name and namespace in other branches
- 6.2 web_server/ssl/hosting_ssl.nodeapi.inc \hosting_ssl_save_key()
- 7.3 web_server/ssl/hosting_ssl.nodeapi.inc \hosting_ssl_save_key()
Store the SSL Cert key in the database.
1 call to hosting_ssl_save_key()
- hosting_ssl_nodeapi_site_presave in web_server/
ssl/ hosting_ssl.nodeapi.inc - Implements hook_nodeapi_TYPE_OP().
File
- web_server/
ssl/ hosting_ssl.nodeapi.inc, line 347 - NodeAPI functions for the Hosting SSL module.
Code
function hosting_ssl_save_key($node) {
if (empty($node->ssl_enabled)) {
return 0;
}
$client = hosting_get_client($node->client);
if ($node->ssl_key == HOSTING_SSL_CUSTOM_KEY && !empty($node->ssl_key_new)) {
$ssl_key = $node->ssl_key_new;
$result = db_query("SELECT * FROM {hosting_ssl_cert} WHERE ssl_key = :ssl_key", array(
':ssl_key' => $ssl_key,
));
if ($obj = $result
->fetch()) {
// update
if ($node->client != NULL) {
$obj->client = $client->nid;
}
drupal_write_record("hosting_ssl_cert", $obj, 'cid');
$node->ssl_key = $obj->cid;
}
else {
// insert
$obj = new stdClass();
$obj->ssl_key = $ssl_key;
$obj->client = $client->nid;
$obj->status = 0;
drupal_write_record("hosting_ssl_cert", $obj);
if (!hosting_ip_allocate($obj, $node)) {
form_set_error('ssl_key_new', t("Unable to allocate IP address for certificate, assuming SNI (Server Name Indication) will work (incompatible with Safari and IE on Windows XP, Android 2.2, etc)."));
}
$node->ssl_key = $obj->cid;
}
}
return $node->ssl_key;
}