]> WPIA git - cassiopeia.git/blobdiff - src/crypto/sslUtil.cpp
upd: remarks from FJW
[cassiopeia.git] / src / crypto / sslUtil.cpp
index 3b93b17be21d4fb3afbaef3bb53c48aeae948de5..81db0ba4f1d55db3dcdfd713b8c6cce12917d751 100644 (file)
@@ -33,17 +33,19 @@ std::shared_ptr<X509> loadX509FromFile( const std::string& filename ) {
 
     return std::shared_ptr<X509>(
         key,
-        []( X509 * ref ) {
+        []( X509* ref ) {
             X509_free( ref );
         } );
 }
 
 std::shared_ptr<EVP_PKEY> loadPkeyFromFile( const std::string& filename ) {
-    std::shared_ptr<FILE> f( fopen( filename.c_str(), "r" ), []( FILE * ptr ) {
-        if( ptr ) {
-            fclose( ptr );
-        }
-    } );
+    std::shared_ptr<FILE> f(
+        fopen( filename.c_str(), "r" ),
+        []( FILE* ptr ) {
+            if( ptr ) {
+                fclose( ptr );
+            }
+        } );
 
     if( !f ) {
         return std::shared_ptr<EVP_PKEY>();
@@ -57,7 +59,7 @@ std::shared_ptr<EVP_PKEY> loadPkeyFromFile( const std::string& filename ) {
 
     return std::shared_ptr<EVP_PKEY>(
         key,
-        []( EVP_PKEY * ref ) {
+        []( EVP_PKEY* ref ) {
             EVP_PKEY_free( ref );
         } );
 }
@@ -66,7 +68,9 @@ int gencb( int a, int b, BN_GENCB* g ) {
     ( void ) a;
     ( void ) b;
     ( void ) g;
+
     std::cout << ( a == 0 ? "." : "+" ) << std::flush;
+
     return 1;
 }
 
@@ -86,9 +90,11 @@ static int verify_callback( int preverify_ok, X509_STORE_CTX* ctx ) {
 static std::shared_ptr<DH> dh_param;
 
 std::shared_ptr<SSL_CTX> generateSSLContext( bool server ) {
-    std::shared_ptr<SSL_CTX> ctx = std::shared_ptr<SSL_CTX>( SSL_CTX_new( TLSv1_2_method() ), []( SSL_CTX * p ) {
-        SSL_CTX_free( p );
-    } );
+    std::shared_ptr<SSL_CTX> ctx = std::shared_ptr<SSL_CTX>(
+        SSL_CTX_new( TLSv1_2_method() ),
+        []( SSL_CTX* p ) {
+            SSL_CTX_free( p );
+        } );
 
     if( !SSL_CTX_set_cipher_list( ctx.get(), "HIGH:+CAMELLIA256:!eNull:!aNULL:!ADH:!MD5:-RSA+AES+SHA1:!RC4:!DES:!3DES:!SEED:!EXP:!AES128:!CAMELLIA128" ) ) {
         throw "Cannot set cipher list. Your source is broken.";
@@ -178,7 +184,7 @@ std::shared_ptr<BIO> openSerial( const std::string& name ) {
     return std::shared_ptr<BIO>(
         BIO_new_fd( fileno( f.get() ), 0 ),
         [f]( BIO* b ) {
-            BIO_free(b);
+            BIO_free( b );
         } );
 }
 
@@ -206,6 +212,6 @@ void extractTimes( std::shared_ptr<X509> target,  std::shared_ptr<SignedCertific
 }
 
 bool CAConfig::crlNeedsResign() {
-    std::shared_ptr<CRL> crl( new CRL( path + "/ca.crl" ) );
+    auto crl = std::make_shared<CRL>( path + "/ca.crl" );
     return crl->needsResign();
 }