2017-11-23 4 views
0

Ich möchte öffentliche PGP-Schlüssel vom SEMS-Server mit LDAP löschen oder ändern. Für diesen Zweck verwende ich LDAP SDK von UnboundID und Didisoft PGP java Bibliothek. Wenn ich die Codes sowohl connection.modify(request) und connection.delete(request) gebe das gleiche Ergebnis Erfolg, aber nicht vom Server gelöscht, kann ich immer noch die Schlüssel auf dem Server sehen. Mein Code geht auf diese Weise.PGP-Schlüssel können nicht von Symantec Encryption Management Server mit LDAP gelöscht oder geändert werden.

Für Modification

if (keyFound) 
    { 
    byte[] bytes = keyStr.getBytes(); 
    this.tmpKS.purge(); 
    KeyPairInformation[] keysTmp = this.tmpKS.importKeyRing(new ByteArrayInputStream(bytes)); 
    KeyPairInformation tmpKeys = keysTmp[0]; 
    String certIdS = Long.toHexString(tmpKeys.getKeyID()).toUpperCase(); 
    for (int i = 0; i < 16 - certIdS.length(); i++) { 
     certIdS = "0" + certIdS; 
    } 
    object = "pgpCertID=" + certIdS + "," + keysDn; 
    ModifyRequest request = new ModifyRequest(object, new Modification[] { new Modification(ModificationType.REPLACE, "pgpCertID", certId), new Modification(ModificationType.REPLACE, "pgpKeyID", key.getKeyIDHex()), new Modification(ModificationType.REPLACE, "pgpKeyType", key.getAlgorithm()), new Modification(ModificationType.REPLACE, "pgpKeyCreateTime", keyCreationTime), new Modification(ModificationType.REPLACE, "pgpSignerID", certId), new Modification(ModificationType.REPLACE, "pgpRevoked", key.isRevoked() ? "1" : "0"), new Modification(ModificationType.REPLACE, "pgpCertID", certId), new Modification(ModificationType.REPLACE, "pgpDisabled", "0"), new Modification(ModificationType.REPLACE, "pgpKeyID", key.getKeyIDHex()), new Modification(ModificationType.REPLACE, "pgpKeyType", key.getAlgorithm()), new Modification(ModificationType.REPLACE, "pgpUserID", key.getUserID() + '\000'), new Modification(ModificationType.REPLACE, "pgpSignerID", certId), new Modification(ModificationType.REPLACE, "pgpKeySize", padLeft(key.getKeySize(), 5)), new Modification(ModificationType.REPLACE, "pgpDisabled", "0"), new Modification(ModificationType.REPLACE, "objectClass", "pgpKeyInfo"), new Modification(ModificationType.REPLACE, "pgpKey", tmpOut.toByteArray()) }); 
    for (int i = 0; i < keysTmp.length; i++) { 
     request.addModification(new Modification(ModificationType.REPLACE, "pgpSubKeyID", Long.toHexString(keysTmp[i].getKeyID()).toUpperCase())); 
    } 
    LDAPResult result = connection.modify(request); 
    return result.getResultCode().intValue() == 0; 
} 

und Für Delete Zweck

if (keyFound) 
{ 
    byte[] bytes = keyStr.getBytes(); 
    this.tmpKS.purge(); 
    KeyPairInformation[] keysTmp = this.tmpKS.importKeyRing(new ByteArrayInputStream(bytes)); 
    KeyPairInformation tmpKeys = keysTmp[0]; 
    String certIdS = Long.toHexString(tmpKeys.getKeyID()).toUpperCase(); 
    for (int i = 0; i < 16 - certIdS.length(); i++) { 
     certIdS = "0" + certIdS; 
    } 
    object = "pgpCertID=" + certIdS + "," + keysDn; 
    DeleteRequest request1 = new DeleteRequest(object); 
    LDAPResult result1 = connection.delete(request1); 
    LDAPResult result = connection.modify(request); 
    return result.getResultCode().intValue() == 0; 
} 

LDAP Ergebnis: LDAPResult (Result = 0 (Erfolg), messageID = 3, opType = 'ändern ')

Antwort

0

Der übliche Weg, einen alten Schlüssel zu entfernen und einen neuen zu schieben, besteht darin, den alten zu widerrufen, ihn hochzuladen und anschließend den neuen hochzuladen.

Im Fall, wenn Sie die alten privaten Schlüssel verloren haben, noch ein Widerruf-Zertifikat dann gemäß dem PGP SDK von Symantec ist es eine Methode:

PGPDeleteFromKeyServer(PGPKeyServerRef  inKeyServerRef, 
PGPKeySetRef inKeysToDelete, 
PGPKeySetRef * outKeysThatFailed  
) 

Hinweis: Die Schlüssel-Server-Verbindung haben muß wurde mit einem Zugriffstyp von kPGPKeyServerAccessType_Administrator eingerichtet.

Wenn Sie eine LDAP-Verbindung herstellen, die als LDAP-Benutzer mit Administratorberechtigung authentifiziert wurde, müssen Sie den Löschvorgang ausführen können.

Verwandte Themen