#include "database.h"
#include "record.h"
#include "opensslBIO.h"
+#include "remoteSigner.h"
#include "simpleOpensslSigner.h"
#include "slipBio.h"
std::shared_ptr<STACK_OF( X509_NAME )> cert_names(
SSL_load_client_CA_file( "testdata/server.crt" ),
[]( STACK_OF( X509_NAME ) *st ) {
- std::cout << "freeing" << std::endl;
sk_X509_NAME_free( st );
} );
attr.c_cflag &= ~( CSIZE | PARENB );
attr.c_cflag |= CS8;
+ cfsetispeed( &attr, B115200 );
+ cfsetospeed( &attr, B115200 );
+
if( tcsetattr( fileno( f ), TCSANOW, &attr ) ) {
throw "failed to get attrs";
}
cert->csr_content = data;
cert->md = "sha256";
cert->profile = "1";
+ std::shared_ptr<AVA> ava( new AVA() );
+ ava->name = "CN";
+ ava->value = "Dummy user certificates";
+ cert->AVAs.push_back( ava );
+ std::shared_ptr<SAN> san( new SAN() );
+ san->type = "DNS";
+ san->content = "n42.example.com";
+ cert->SANs.push_back( san );
auto res = sign->sign( cert );
- std::cout << "sent things" << std::endl;
+ std::cout << "log: " << res->log << std::endl;
+ std::cout << "cert things: " << res->certificate << std::endl;
return 0;
}
send( conn, head, RecordHeader::SignerCommand::SET_SIGNATURE_TYPE, cert->md );
send( conn, head, RecordHeader::SignerCommand::SET_PROFILE, cert->profile );
- send( conn, head, RecordHeader::SignerCommand::ADD_AVA, "CN,commonName" );
- send( conn, head, RecordHeader::SignerCommand::ADD_SAN, "DNS,*.example.com" );
+
+ for( auto ava : cert->AVAs ) {
+ if( ava->name.find( "," ) != std::string::npos ) {
+ // invalid ava
+ return std::shared_ptr<SignedCertificate>();
+ }
+
+ send( conn, head, RecordHeader::SignerCommand::ADD_AVA, ava->name + "," + ava->value );
+ }
+
+ for( auto san : cert->SANs ) {
+ if( san->type.find( "," ) != std::string::npos ) {
+ // invalid ava
+ return std::shared_ptr<SignedCertificate>();
+ }
+
+ send( conn, head, RecordHeader::SignerCommand::ADD_SAN, san->type + "," + san->content );
+ }
+
send( conn, head, RecordHeader::SignerCommand::SIGN, "" );
send( conn, head, RecordHeader::SignerCommand::LOG_SAVED, "" );
std::shared_ptr<SignedCertificate> result = std::shared_ptr<SignedCertificate>( new SignedCertificate() );
int length = conn->read( buffer.data(), buffer.size() );
RecordHeader head;
std::string payload = parseCommand( head, std::string( buffer.data(), length ) );
- std::cout << "Data: " << std::endl << payload << std::endl;
+
+ switch( ( RecordHeader::SignerResult ) head.command ) {
+ case RecordHeader::SignerResult::CERTIFICATE:
+ result->certificate = payload;
+ break;
+
+ case RecordHeader::SignerResult::SAVE_LOG:
+ result->log = payload;
+ break;
+ }
} catch( const char* msg ) {
std::cout << msg << std::endl;
return std::shared_ptr<SignedCertificate>();