Skip to content

Comments

added X509_verify(cert, serverPubKey)#3861

Merged
marinofaggiana merged 3 commits intomasterfrom
verify-certificate-digital-sign
Nov 10, 2025
Merged

added X509_verify(cert, serverPubKey)#3861
marinofaggiana merged 3 commits intomasterfrom
verify-certificate-digital-sign

Conversation

@marinofaggiana
Copy link
Member

  • added E2EE X509_verify

Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com>
Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com>
Copy link

@alperozturk96 alperozturk96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will compare with Android

Copy link

@alperozturk96 alperozturk96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created certificate from Android and tested on iOS, certificate verification working.

@marinofaggiana You can check my optional suggestion for code changes.

if error == .success, let publicKey {

// Verify Certificate
var verifyCertificate: Bool = false
Copy link

@alperozturk96 alperozturk96 Nov 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic can be deduplicated for createNewE2EE and getPrivateKeyCipher.

Function:

private func verifyCertificate(_ account: String, _ publicKey: String) -> Bool {
  var result = false

  if let certificate = NCPreferences().getEndToEndCertificate(account: account) {
    result = NCEndToEndEncryption.shared().verifyCertificate(certificate, publicKey: publicKey)
  }

  if result == false {
    let error = NKError(
      errorCode: NCGlobal.shared.errorInternalError,
      errorDescription: "Serious internal error to verify certificate")
    NCContentPresenter().messageNotification(
      "E2E verify certificate server", error: error, delay: NCGlobal.shared.dismissAfterSecond,
      type: NCContentPresenter.messageType.error, priority: .max)
  }

  return result
}

Usage in createNewE2EE and getPrivateKeyCipher.:

if error == .success, let publicKey {
  let verifyCertificate = self.verifyCertificate(account, publicKey)
  if !verifyCertificate {
    return
  }

  NCPreferences().setEndToEndPublicKey(account: account, publicKey: publicKey)
  NCManageDatabase.shared.clearTablesE2EE(account: account)

  self.delegate?.endToEndInitializeSuccess(metadata: self.metadata)

}

@marinofaggiana
Copy link
Member Author

Thanks for your suggestion but this class needs to be totally rewritten in asyn when I have time

@marinofaggiana marinofaggiana merged commit 0fb21e4 into master Nov 10, 2025
4 of 5 checks passed
@marinofaggiana marinofaggiana deleted the verify-certificate-digital-sign branch November 10, 2025 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants