Uploaded image for project: 'EJBCA'
  1. EJBCA
  2. ECA-6298

CaInfo.getCertificateChain should return a List instead of a Collection

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Cosmetic
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: EJBCA 6.12.0
    • Component/s: None
    • Labels:
    • Sprint:
      EJBCA Happy Fun Sprint (6)

      Description

      The method getCertificateChain in CaInfo returns a Collection, but it should return a List.

      /** Retrieves the certificate chain for the CA. The returned certificate chain MUST have the
        * RootCA certificate in the last position and the CAs certificate in the first.
        */
      public Collection<Certificate> getCertificateChain() {
          if (certificatechain == null) {
              return null;
          }
          if (certificatechainCached == null) {
              certificatechainCached = EJBTools.unwrapCertCollection(certificatechain);
          }
          return certificatechainCached;
      }
      

      The javadoc says that the RootCA certificate should be in the last position, but a Collection does not enforce any order of its elements. Currently this does not lead to any problems because the Collection is a List, but the API does not convey this fact.

      Similar problems where the "first" element is fetched with myCollection.iterator().next() should be identified and fixed.

      We should also kill off code like this

      if (certificateChain != null) {
          Iterator<Certificate> iterator = certificateChain.iterator();
              while (iterator.hasNext()) {
                  tmp = iterator.next();
              }
      }
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              bastianf Bastian Fredriksson
              Reporter:
              bastianf Bastian Fredriksson
              Verified by:
              Mike Agrenius Kushner
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 30 minutes Original Estimate - 30 minutes
                  30m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 hour, 11 minutes
                  1h 11m