You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

49 lines
1.6 KiB

<?php
$Data = array();
$Data[] = "[ req ]";
$Data[] = "req_extensions = req_ext";
$Data[] = "subjectAltName = @alt_names";
$Data[] = "authorityKeyIdentifier = keyid,issuer";
$Data[] = "basicConstraints = CA:FALSE";
$Data[] = "distinguished_name = req_distinguished_name";
$Data[] = "prompt = no";
$Data[] = "[ req_distinguished_name ]";
$Data[] = "commonName=Argus Sensor Module";
$Data[] = "[ req_ext ]";
$Data[] = "subjectAltName = @alt_names";
$Data[] = "[ alt_names ]";
$IPS = array();
$IPS[] = "10.0.0.1";
if( count( $argv ) > 1 ){
$TMP = md5(time());
$FD = fopen( $TMP.".conf", "w+" );
if( $FD ){
for( $i = 1; $i < count( $argv ); $i++ ){
$IPS[] = $argv[$i];
};
$OIP = array();
$CC = 1;
foreach( $IPS as $I ){
$OIP[] = 'IP.'.$CC.' = '.$I;
$CC++;
};
$JJ = implode( "\n", $Data ) . "\n";
fprintf( $FD, $JJ );
$JJ = implode( "\n", $OIP ) . "\n";
fprintf( $FD, $JJ );
fclose( $FD );
if( 0 ){
$L = `openssl genrsa -out {$TMP}.key 2048`;
$L = `openssl req -sha256 -verbose -config {$TMP}.conf -extensions req_ext -new -nodes -key {$TMP}.key -out {$TMP}.csr`;
} else {
$L = `openssl req -sha256 -verbose -config {$TMP}.conf -extensions req_ext -new -nodes -key host.key -out {$TMP}.csr`;
};
$L = `openssl x509 -req -CA rootCA.crt -CAkey rootCA.key -in {$TMP}.csr -out {$TMP}.crt -days 365 -CAcreateserial -extfile {$TMP}.conf -extensions req_ext`;
unlink( $TMP . '.conf' );
unlink( $TMP . '.csr' );
};
};
?>