Skip to content
Snippets Groups Projects
Commit 297957be authored by Malte Bauch's avatar Malte Bauch
Browse files

Allow to reset key store through qkdn-manager api

See merge request !229
parent 3888d20e
No related branches found
No related tags found
1 merge request!229Allow to reset key store through qkdn-manager api
Pipeline #228077 passed
......@@ -75,6 +75,10 @@ func (qm *DanetQuantumModule) Address() string {
return qm.addr
}
func (qm *DanetQuantumModule) SetActive(active bool) {
qm.active = active
}
func (qm *DanetQuantumModule) IsActive() bool {
return qm.active
}
......
......@@ -151,6 +151,10 @@ func (qm *ETSI014HTTPQuantumModule) MaxKeyFillLevel() uint64 {
return qm.maxKeyFillLevel
}
func (qm *ETSI014HTTPQuantumModule) SetActive(active bool) {
qm.active = active
}
func (qm *ETSI014HTTPQuantumModule) IsActive() bool {
return qm.active
}
......
......@@ -219,3 +219,21 @@ func (kp *KmsPeer) SetStatus(updateStatus KmsPeerStatus) {
func (kp *KmsPeer) GetKmsPeerId() uuid.UUID {
return kp.peerKmsId
}
func (kp *KmsPeer) ResetKeyStore(kmsId string) error {
switch client := kp.peerClient; {
case client.KmsTalkerClient != nil:
_, err := client.InterComCapabilities(context.Background(), &pbIC.InterComCapabilitiesRequest{
Timestamp: time.Now().Unix(),
KmsId: kmsId,
ResetKeyStore: true,
})
if err != nil {
return err
}
default:
return fmt.Errorf("No active peer client found")
}
return nil
}
......@@ -23,5 +23,6 @@ type QuantumModule interface {
Sync() error
Address() string
IsActive() bool
SetActive(bool)
Reset()
}
......@@ -220,6 +220,12 @@ func (qs *QkdnManagerServer) handleSetKeyStore(w http.ResponseWriter, r *http.Re
return
}
} else if fetch == "false" {
eqm.SetActive(false)
if err := peer.ResetKeyStore(qs.kms.GetID().String()); err != nil {
eqm.SetActive(true)
http.Error(w, fmt.Sprintf("Failed to reset keystore for quantum module of peer: %s", peerID), http.StatusBadRequest)
return
}
eqm.Reset()
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment