concrete/src/Api/ApiServiceProvider.php
private function getKeyPair()
    {
        $config = $this->app->make('config/database');

        // Seee if we already have a kypair
        $keyPair = $config->get('api.keypair');

        if (!$keyPair) {
            $rsa = $this->app->make(RSA::class);

            // Generate a new RSA key
            $keyPair = $rsa->createKey(2048);

            foreach ($keyPair as &$item) {
                $item = str_replace("\r\n", "\n", $item);
            }

            // Save the keypair
            $config->save('api.keypair', $keyPair);
        }

        return $keyPair;
    }
private function getKeyPair()
    {
        $config = $this->app->make('config/database');

        // Seee if we already have a kypair
        $keyPair = $config->get('api.keypair');

        if (!$keyPair) {
            $rsa = $this->app->make(RSA::class);

            // Generate a new RSA key
            $keyPair = $rsa->createKey(2048);

            foreach ($keyPair as &$item) {
                $item = str_replace("\r\n", "\n", $item);
            }

            // Save the keypair
            $config->save('api.keypair', $keyPair);
        }

        return $keyPair;
    }
private function getKeyPair ( ) { $ config = $ this -> app -> make ( 'config/database' ) ; // Seee if we already have a kypair $ keyPair = $ config -> get ( 'api.keypair' ) ; if ( ! $ keyPair ) { $ rsa = $ this -> app -> make ( RSA :: class ) ; // Generate a new RSA key $ keyPair = $ rsa -> createKey ( 2048 ) ; foreach ( $ keyPair as & $ item ) { $ item = str_replace ( "\r\n" , "\n" , $ item ) ; } // Save the keypair $ config -> save ( 'api.keypair' , $ keyPair ) ; } return $ keyPair ; }
Generate new RSA keys if needed
@return string[] ['privatekey' => '...', 'publickey' => '...']
Generate new RSA keys if needed