etesync / etesync-dav

This is a CalDAV and CardDAV adapter for EteSync
https://www.etesync.com
GNU General Public License v3.0
285 stars 45 forks source link

Unfriendly interface when certificate is already exists #226

Open sergeyklay opened 3 years ago

sergeyklay commented 3 years ago

Hello,

This is what is see when I try to generate certificate:

$ etesync-dav certgen
Skipping key generation as already exists.
security: SecKeychainItemImport: The specified item already exists in the keychain.
Traceback (most recent call last):
  File "etesync-dav", line 89, in <module>
  File "etesync-dav", line 80, in certgen
  File "etesync_dav/mac_helpers.py", line 117, in trust_cert
  File "etesync_dav/mac_helpers.py", line 103, in macos_trust_cert
  File "subprocess.py", line 364, in check_call
subprocess.CalledProcessError: Command '['security', 'import', '/Users/serghei/Library/Application Support/etesync-dav/etesync.crt']' returned non-zero exit status 1.
[74884] Failed to execute script etesync-dav

There is no even help:

$ etesync-dav certgen --help
Skipping key generation as already exists.
security: SecKeychainItemImport: The specified item already exists in the keychain.
Traceback (most recent call last):
  File "etesync-dav", line 89, in <module>
  File "etesync-dav", line 80, in certgen
  File "etesync_dav/mac_helpers.py", line 117, in trust_cert
  File "etesync_dav/mac_helpers.py", line 103, in macos_trust_cert
  File "subprocess.py", line 364, in check_call
subprocess.CalledProcessError: Command '['security', 'import', '/Users/serghei/Library/Application Support/etesync-dav/etesync.crt']' returned non-zero exit status 1.
[74890] Failed to execute script etesync-dav

Yes, I can get certificate path from the traceback and remove it by hand but this is unfriendly. Anyway end users should not see Python tracebacks when working with etesync-dav. It would be nice to have --help and --force options IMO.

P.S. After removing file by hand:

$ etesync-dav certgen
security: SecKeychainItemImport: The specified item already exists in the keychain.
Traceback (most recent call last):
  File "etesync-dav", line 89, in <module>
  File "etesync-dav", line 80, in certgen
  File "etesync_dav/mac_helpers.py", line 117, in trust_cert
  File "etesync_dav/mac_helpers.py", line 103, in macos_trust_cert
  File "subprocess.py", line 364, in check_call
subprocess.CalledProcessError: Command '['security', 'import', '/Users/serghei/Library/Application Support/etesync-dav/etesync.crt']' returned non-zero exit status 1.
[74926] Failed to execute script etesync-dav

The specified item already exists in the keychain.

Hmmm... Which one? I have hundreds of items in the keychain.