Adds main cert & fixes some typos

这个提交包含在:
Peter Goodhall 2020-08-26 16:31:35 +01:00
父节点 02f0a741b5
当前提交 94f3060419
共有 5 个文件被更改,包括 39 次插入10 次删除

查看文件

@ -21,7 +21,7 @@ $config['migration_enabled'] = TRUE;
| be upgraded / downgraded to. | be upgraded / downgraded to.
| |
*/ */
$config['migration_version'] = 44; $config['migration_version'] = 45;
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------

查看文件

@ -103,14 +103,14 @@ class Lotw extends CI_Controller {
// New Certificate Store in Database // New Certificate Store in Database
// Store Certificate Data into MySQL // Store Certificate Data into MySQL
$this->LotwCert->store_certficiate($this->session->userdata('user_id'), $info['issued_callsign'], $dxcc, $info['validFrom'], $info['validTo_Date'], $info['pem_key']); $this->LotwCert->store_certficiate($this->session->userdata('user_id'), $info['issued_callsign'], $dxcc, $info['validFrom'], $info['validTo_Date'], $info['pem_key'], $info['general_cert']);
// Cert success flash message // Cert success flash message
$this->session->set_flashdata('Success', $info['issued_callsign'].' Certficiate Imported.'); $this->session->set_flashdata('Success', $info['issued_callsign'].' Certficiate Imported.');
} else { } else {
// Certficiate is in the system time to update // Certficiate is in the system time to update
$this->LotwCert->update_certficiate($this->session->userdata('user_id'), $info['issued_callsign'], $dxcc, $info['validFrom'], $info['validTo_Date'], $info['pem_key']); $this->LotwCert->update_certficiate($this->session->userdata('user_id'), $info['issued_callsign'], $dxcc, $info['validFrom'], $info['validTo_Date'], $info['pem_key'], $info['general_cert']);
// Cert success flash message // Cert success flash message
$this->session->set_flashdata('Success', $info['issued_callsign'].' Certficiate Updated.'); $this->session->set_flashdata('Success', $info['issued_callsign'].' Certficiate Updated.');
@ -237,11 +237,16 @@ class Lotw extends CI_Controller {
$password = $password; // Only needed if 12 has a password set $password = $password; // Only needed if 12 has a password set
$filename = file_get_contents('file://'.$file); $filename = file_get_contents('file://'.$file);
$worked = openssl_pkcs12_read($filename, $results, $password); $worked = openssl_pkcs12_read($filename, $results, $password);
$data['general_cert'] = $results['cert'];
if($worked) { if($worked) {
// Reading p12 successful // Reading p12 successful
$new_password = "cloudlog"; // set default password $new_password = "cloudlog"; // set default password
$result = null; $result = null;
$worked = openssl_pkey_export($results['pkey'], $result, $new_password); $worked = openssl_pkey_export($results['pkey'], $result, $new_password);
if($worked) { if($worked) {
// Store PEM Key in Array // Store PEM Key in Array
$data['pem_key'] = $result; $data['pem_key'] = $result;

查看文件

@ -0,0 +1,21 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Migration_add_cert_to_lotw_certs extends CI_Migration {
public function up()
{
$fields = array(
'cert TEXT',
);
$this->dbforge->add_column('lotw_certs', $fields);
}
public function down()
{
$this->dbforge->drop_column('lotw_certs', 'cert');
}
}

查看文件

@ -40,7 +40,7 @@ class LotwCert extends CI_Model {
return $query->num_rows(); return $query->num_rows();
} }
function store_certficiate($user_id, $callsign, $dxcc, $date_created, $date_expires, $cert_key) { function store_certficiate($user_id, $callsign, $dxcc, $date_created, $date_expires, $cert_key, $general_cert) {
$data = array( $data = array(
'user_id' => $user_id, 'user_id' => $user_id,
'callsign' => $callsign, 'callsign' => $callsign,
@ -48,17 +48,19 @@ class LotwCert extends CI_Model {
'date_created' => $date_created, 'date_created' => $date_created,
'date_expires' => $date_expires, 'date_expires' => $date_expires,
'cert_key' => $cert_key, 'cert_key' => $cert_key,
'cert' => $general_cert,
); );
$this->db->insert('lotw_certs', $data); $this->db->insert('lotw_certs', $data);
} }
function update_certficiate($user_id, $callsign, $dxcc, $date_created, $date_expires, $cert_key) { function update_certficiate($user_id, $callsign, $dxcc, $date_created, $date_expires, $cert_key, $general_cert) {
$data = array( $data = array(
'cert_dxcc' => $dxcc, 'cert_dxcc' => $dxcc,
'date_created' => $date_created, 'date_created' => $date_created,
'date_expires' => $date_expires, 'date_expires' => $date_expires,
'cert_key' => $cert_key, 'cert_key' => $cert_key,
'cert' => $general_cert
); );
$this->db->where('user_id', $user_id); $this->db->where('user_id', $user_id);

查看文件

@ -2,14 +2,15 @@
header('Content-Type: text/plain; charset=utf-8'); header('Content-Type: text/plain; charset=utf-8');
?> ?>
<?php <?php
$cert1 = str_replace("-----BEGIN ENCRYPTED PRIVATE KEY-----", "", $lotw_cert_info->cert_key); $clean_cert = trim($lotw_cert_info->cert);
$cert2 = str_replace("-----END ENCRYPTED PRIVATE KEY-----", "", $cert1); $cert1 = str_replace("-----BEGIN CERTIFICATE-----", "", $clean_cert);
$cert2 = str_replace("-----END CERTIFICATE-----", "", $cert1);
?> ?>
<TQSL_IDENT:53>TQSL V2.5.1 Lib: V2.5 Config: V11.9 AllowDupes: false <TQSL_IDENT:54>TQSL V2.5.4 Lib: V2.5 Config: V11.12 AllowDupes: false
<Rec_Type:5>tCERT <Rec_Type:5>tCERT
<CERT_UID:1>1 <CERT_UID:1>1
<CERTIFICATE:<?php echo strlen(trim($cert2)); ?>><?php echo trim($cert2); ?> <CERTIFICATE:<?php echo strlen(trim($cert2)) + 1; ?>><?php echo trim($cert2); ?>
<eor> <eor>
@ -121,7 +122,7 @@ if($qso->COL_SAT_NAME) {
$signed_item = $CI->signlog($lotw_cert_info->cert_key, $sign_string); $signed_item = $CI->signlog($lotw_cert_info->cert_key, $sign_string);
?> ?>
<SIGN_LOTW_V2.0:<?php echo strlen($signed_item); ?>:6><?php echo $signed_item; ?> <SIGN_LOTW_V2.0:<?php echo strlen($signed_item)+1; ?>:6><?php echo $signed_item; ?>
<SIGNDATA:<?php echo strlen($sign_string); ?>><?php echo $sign_string; ?> <SIGNDATA:<?php echo strlen($sign_string); ?>><?php echo $sign_string; ?>