code: private void saveCertificateFromResponse(Response response) {
          try {
              String responseBody = response.getResponseText();
              JSONObject jsonResponse = new JSONObject(responseBody);
  
              //handle certificate
              String certificateString = jsonResponse.getString("certificate");
              X509Certificate certificate = CertificatesUtility.base64StringToCertificate(certificateString);
  
              CertificatesUtility.checkValidityWithPublicKey(certificate, registrationKeyPair.getPublic());
  
              certificateStore.saveCertificate(registrationKeyPair, certificate);
  
              //save the clientId separately
              preferences.clientId.set(jsonResponse.getString("clientId"));
  
          } catch (Exception e) {
              throw new RuntimeException("Failed to save certificate from response", e);
          }
  
          logger.debug("certificate successfully saved");
      }
docs: Extract the certificate data from response and save it on local storage
  @param response contains the certificate data