@@ -536,8 +536,7 @@ export class PgDataStore implements DataStore, ProvisioningStore {
536536 const cryptoStore = this . cryptoStore ;
537537 if ( config . certificate && row . key && cryptoStore ) {
538538 try {
539- const keyParts = row . key . split ( ',' ) . map ( v => cryptoStore . decrypt ( v ) ) ;
540- config . certificate . key = `-----BEGIN PRIVATE KEY-----\n${ keyParts . join ( '' ) } -----END PRIVATE KEY-----\n` ;
539+ config . certificate . key = cryptoStore . decryptLargeString ( row . key ) ;
541540 }
542541 catch ( ex ) {
543542 log . warn ( `Failed to decrypt TLS key for ${ userId } ${ domain } ` , ex ) ;
@@ -565,16 +564,7 @@ export class PgDataStore implements DataStore, ProvisioningStore {
565564
566565 if ( config . certificate && this . cryptoStore ) {
567566 keypair . cert = config . certificate . cert ;
568- const cryptoParts = [ ] ;
569- let key = config . certificate . key ;
570- // We can't store these as our encryption system doesn't support spaces.
571- key = key . replace ( '-----BEGIN PRIVATE KEY-----\n' , '' ) . replace ( '-----END PRIVATE KEY-----\n' , '' ) ;
572- while ( key . length > 0 ) {
573- const part = key . slice ( 0 , 64 ) ;
574- cryptoParts . push ( this . cryptoStore . encrypt ( part ) ) ;
575- key = key . slice ( 64 ) ;
576- }
577- keypair . key = cryptoParts . join ( ',' ) ;
567+ keypair . key = this . cryptoStore . encryptLargeString ( config . certificate . key ) ;
578568 }
579569 const parameters = {
580570 user_id : userId ,
@@ -679,6 +669,12 @@ export class PgDataStore implements DataStore, ProvisioningStore {
679669 [ userId , domain ] ) ;
680670 }
681671
672+ public async removeClientCert ( userId : string , domain : string ) : Promise < void > {
673+ await this . pgPool . query (
674+ "UPDATE client_config SET cert = NULL AND key = NULL WHERE user_id = $1 AND domain = $2" ,
675+ [ userId , domain ] ) ;
676+ }
677+
682678 public async getMatrixUserByUsername ( domain : string , username : string ) : Promise < MatrixUser | undefined > {
683679 // This will need a join
684680 const res = await this . pgPool . query (
0 commit comments