Skip to content

Conversation

@epoberezkin
Copy link
Member

@epoberezkin epoberezkin commented May 5, 2025

SMP server:

  • handshake:
    • request and optionally pass client certificate to SMP server
    • SMP handshake with additional server response 8558f2f
    • get/create service record in handshake (currently, there is no database access in handshake, probably should be done via hook).
  • verification
    • validate that command is allowed for service/role combination 9734edc
    • verify service signature 9734edc
  • process server commands:
    • associate messaging service ID with queue
      • NEW command
      • SUB command (change response to SOK in all cases)
      • NSUB command (change response to SOK)
    • process SSUB command
    • process NSSUB command
    • process subscribed client/service changes in serverThread
  • deliver events to connected service, based on associated service ID:
    • messages
    • notifications
    • DELD
    • END to individually subscribed connections when service subscribes, and vice versa
  • statistics
    • encode/decode
    • include in prometheus
  • storage
    • stm
    • postgres

Notification server:

  • initial subscription:
    • handover to service (association).
    • re-handover if service ID changes in handshake or service becomes unavailable.
    • service subscription for queues that have the same service ID as in handshake.
  • service subscriptions workers in "small agent"
  • create association with service ID in CASubscribed
  • additional "small agent" events when service subscriptions succeed/end
  • prometheus: track counts of subscribed queues in service subscriptions

Chat Agent:

  • network setting to create certificates for the service, one per user+server combination.
  • send certificate in TLS/SMP handshakes, store service ID.
  • create association:
    • creating queue (newRcvQueue) when creating connection, joining and switching connections
    • response to subscriptions.
  • return service association in async responses.
  • service subscription agent API - should accept user and service ID, respond with error if handshake reports different service ID, so that chat can re-handover.
  • account for service subscriptions in agent stats

Chat Core:

  • probably, should store service association on connections too.
  • maintain the set of subscribed services, report them to UI, so that spinners disappear.
  • initial subscription - read services for all connections, read unassociated connections only to handover.
  • re-handover on agent error (if service ID changes).

@epoberezkin epoberezkin requested a review from spaced4ndy as a code owner May 5, 2025 13:33
@epoberezkin epoberezkin changed the title rfc: client certificates for high volume clients (opertors' chat rela… rfc: client certificates for high volume clients (opertors' chat relays, notification servers, service bots) May 5, 2025
@epoberezkin epoberezkin changed the title rfc: client certificates for high volume clients (opertors' chat relays, notification servers, service bots) rfc: client certificates for servers using SMP protocol as clients (opertors' chat relays, notification servers, service bots) May 5, 2025
@epoberezkin epoberezkin force-pushed the ep/rfc-client-certs branch 3 times, most recently from cee2158 to 54f580e Compare May 15, 2025 17:55
@epoberezkin epoberezkin force-pushed the ep/rfc-client-certs branch from 54f580e to d7c5e14 Compare May 15, 2025 18:56
@epoberezkin epoberezkin force-pushed the ep/rfc-client-certs branch 4 times, most recently from a1cadfd to c230c34 Compare May 17, 2025 08:20
@epoberezkin epoberezkin force-pushed the ep/rfc-client-certs branch from c230c34 to 4cd017f Compare May 17, 2025 09:17
@epoberezkin epoberezkin force-pushed the ep/rfc-client-certs branch from 397ffba to 1077110 Compare May 19, 2025 18:39
@epoberezkin epoberezkin force-pushed the ep/rfc-client-certs branch from 1077110 to 9734edc Compare May 19, 2025 18:42
@epoberezkin epoberezkin force-pushed the ep/rfc-client-certs branch from 6bd58a6 to c718edd Compare May 20, 2025 09:32
@epoberezkin
Copy link
Member Author

src/Simplex/Messaging/Protocol.hs - protocol changes: commands and transmission encodings for the second signature

SMP server

  • src/Simplex/Messaging/Server.hs - service/command verification, commands, serverThread function for subscription logistics
  • src/Simplex/Messaging/Server/QueueStore/Postgres.hs
  • src/Simplex/Messaging/Server/QueueStore/Postgres/Migrations.hs
  • src/Simplex/Messaging/Server/QueueStore/STM.hs

src/Simplex/Messaging/Transport.hs - transport handshake with the 3rd message for services

src/Simplex/Messaging/Transport/Client.hs - send service certificate

src/Simplex/Messaging/Transport/Server.hs - request service certificate

src/Simplex/Messaging/Client.hs - SMP command functions, service authentication

NTF server

  • src/Simplex/Messaging/Notifications/Server.hs
  • src/Simplex/Messaging/Notifications/Server/Store/Migrations.hs
  • src/Simplex/Messaging/Notifications/Server/Store/Postgres.hs

New tests

  • tests/ServerTests.hs - receiving notifications via service subscriptions
  • tests/AgentTests/NotificationTests.hs - migration to/from service subscriptions

@epoberezkin epoberezkin force-pushed the ep/rfc-client-certs branch from fd18a33 to 500210f Compare June 5, 2025 13:30
@epoberezkin epoberezkin force-pushed the ep/rfc-client-certs branch 2 times, most recently from 339a46e to 25dd788 Compare June 5, 2025 20:54
@epoberezkin epoberezkin force-pushed the ep/rfc-client-certs branch from 5b67657 to 6872bd4 Compare June 5, 2025 21:43
@epoberezkin epoberezkin force-pushed the ep/rfc-client-certs branch from 6872bd4 to a75c96d Compare June 5, 2025 22:10
@epoberezkin epoberezkin merged commit 5241f5f into master Jun 6, 2025
2 of 4 checks passed
@epoberezkin epoberezkin deleted the ep/rfc-client-certs branch June 6, 2025 07:03
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