VirtualBox

Changeset 60334 in vbox for trunk


Ignore:
Timestamp:
Apr 5, 2016 1:55:31 PM (9 years ago)
Author:
vboxsync
Message:

CertificateImpl,ApplianceImpl: Drop the unwanted presence attribute and replaced by returning NULL object in IAppliance::getCertificate. Move the certificate object to the data structure. Dropped the clearly unwanted init() method that (a) kept wanting to relate to IAppliance which I though I made clear several times it should not, (b) create an Certificate object in a unready state where most attributes would assert in debug builds and possibly crash. Renamed the CertificateVersion bits and redid the query method to no assume stuff.

Location:
trunk/src/VBox/Main
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r60328 r60334  
    29822982  <enum
    29832983    name="CertificateVersion"
    2984     uuid="394b00ce-4b60-45ff-abe1-f58221d4f73b"
    2985     >
    2986     <desc>
    2987         Possible version of certificate
    2988     </desc>
    2989     <const name="Unknown"    value="0"/>
    2990     <const name="One"    value="1"/>
    2991     <const name="Two"    value="2"/>
    2992     <const name="Three"    value="3"/>
    2993     <const name="Four"    value="4"/>
     2984    uuid="9e232a99-51d0-4dbd-96a0-ffac4bc3e2a8"
     2985    >
     2986    <desc>
     2987        X.509 certificate version numbers.
     2988    </desc>
     2989    <const name="V1"       value="1"/>
     2990    <const name="V2"       value="2"/>
     2991    <const name="V3"       value="3"/>
     2992    <const name="Unknown"  value="99"/>
    29942993  </enum>
    29952994
     
    30002999  <interface
    30013000    name="ICertificate" extends="$unknown"
    3002     uuid="336064ce-c853-4bd0-ad6c-b42d8ed99e5e"
     3001    uuid="c85f71ef-dd7f-4b9c-aa58-5c186a95d7f9"
    30033002    wsmap="managed"
    3004     reservedAttributes="4" reservedMethods="2"
    3005     >
    3006     <desc>
    3007         X509 certificate details.
     3003    reservedAttributes="12" reservedMethods="2"
     3004    >
     3005    <desc>
     3006        X.509 certificate details.
    30083007    </desc>
    30093008    <attribute name="versionNumber" type="CertificateVersion" readonly="yes">
     
    30293028    </attribute>
    30303029    <attribute name="validityPeriodNotBefore" type="wstring" readonly="yes">
    3031       <desc>Time stamp in milliseconds since 1970-01-01 UTC.</desc>
     3030      <desc>Certificate not valid before ISO time stamp.</desc>
    30323031    </attribute>
    30333032    <attribute name="validityPeriodNotAfter" type="wstring" readonly="yes">
    3034       <desc>Time stamp in milliseconds since 1970-01-01 UTC.</desc>
     3033      <desc>Certificate not valid after ISO time stamp.</desc>
    30353034    </attribute>
    30363035    <attribute name="publicKeyAlgorithmOID" type="wstring" readonly="yes">
     
    30683067    <attribute name="trusted" type="boolean" readonly="yes">
    30693068      <desc>Set if the certificate is trusted.</desc>
    3070     </attribute>
    3071     <attribute name="presence" type="boolean" readonly="yes">
    3072       <desc>Returns true in case of presence of certificate.</desc>
    3073     </attribute>
    3074     <attribute name="verified" type="boolean" readonly="yes">
    3075       <desc>Check whether certificate was verified or not during import.</desc>
    30763069    </attribute>
    30773070
     
    32353228
    32363229    <attribute name="certificate" type="ICertificate" readonly="yes">
    3237       <desc> X509 certificate information given to user if certificate exists in the OVF package
     3230      <desc>
     3231        The X.509 signing certificate, if the imported OVF was signed, @c null
     3232        if not signed.  This is available after calling <link to="#read"/>.
    32383233      </desc>
    32393234    </attribute>
  • trunk/src/VBox/Main/include/ApplianceImpl.h

    r60332 r60334  
    115115    VirtualBox* const mVirtualBox;
    116116
    117     ComObjPtr<Certificate> mptrCertificateInfo;
    118117    struct ImportStack;
    119118    class TaskOVF;
  • trunk/src/VBox/Main/include/ApplianceImplPrivate.h

    r59679 r60334  
    137137        fDeterminedDigestTypes   = false;
    138138        fDigestTypes             = RTMANIFEST_ATTR_SHA1 | RTMANIFEST_ATTR_SHA256 | RTMANIFEST_ATTR_SHA512;
     139        ptrCertificateInfo.setNull();
    139140        strCertError.setNull();
    140141    }
     
    168169    RTVFSFILE           hMemFileTheirManifest;
    169170
    170     /** The signer certificate from the signature fiel (.cert).
     171    /** The signer certificate from the signature file (.cert).
    171172     * This will be used in the future provide information about the signer via
    172173     * the API. */
     
    192193    /** The digest type used to sign the manifest. */
    193194    RTDIGESTTYPE        enmSignedDigestType;
     195    /** The certificate info object.  This is NULL if no signature and
     196     *  successfully loaded certificate. */
     197    ComObjPtr<Certificate> ptrCertificateInfo;
    194198    /** @} */
    195199
  • trunk/src/VBox/Main/include/CertificateImpl.h

    r60328 r60334  
    2828using namespace std;
    2929
    30 class Appliance;
    31 
    3230class ATL_NO_VTABLE Certificate :
    3331    public CertificateWrap
     
    3836    DECLARE_EMPTY_CTOR_DTOR(Certificate)
    3937
    40     HRESULT init(Appliance* appliance);
    4138    HRESULT initCertificate(PCRTCRX509CERTIFICATE a_pCert, bool a_fTrusted);
    4239    void uninit();
     
    4643
    4744private:
    48     const Appliance* m_appliance;
    49 
    5045    // wrapped ICertificate properties
    5146    HRESULT getVersionNumber(CertificateVersion_T *aVersionNumber);
     
    6863    HRESULT getSelfSigned(BOOL *aSelfSigned);
    6964    HRESULT getTrusted(BOOL *aTrusted);
    70     HRESULT getVerified(BOOL *aVerified);
    71     HRESULT getPresence(BOOL *aPresence);
    7265    // wrapped ICertificate methods
    7366    HRESULT queryInfo(LONG aWhat, com::Utf8Str &aResult);
  • trunk/src/VBox/Main/src-server/ApplianceImpl.cpp

    r60332 r60334  
    410410    AssertReturn(m->m_pSecretKeyStore, E_FAIL);
    411411
    412     mptrCertificateInfo.createObject();
    413     mptrCertificateInfo->init(this);
    414 
    415412    i_initApplianceIONameMap();
    416413
     
    527524        return E_ACCESSDENIED;
    528525
    529 /** @todo r=bird: What about when there is no signature and certificate? */
    530     mptrCertificateInfo.queryInterfaceTo(aCertificateInfo.asOutParam());
     526    /* Can be NULL at this point, queryInterfaceto handles that. */
     527    m->ptrCertificateInfo.queryInterfaceTo(aCertificateInfo.asOutParam());
    531528    return S_OK;
    532529}
  • trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp

    r60332 r60334  
    19511951    /** @todo provide details about the signatory, signature, etc.  */
    19521952    if (m->fSignerCertLoaded)
    1953         mptrCertificateInfo->initCertificate(&m->SignerCert, m->fCertificateValid && !m->fCertificateMissingPath);
     1953    {
     1954        m->ptrCertificateInfo.createObject();
     1955        m->ptrCertificateInfo->initCertificate(&m->SignerCert, m->fCertificateValid && !m->fCertificateMissingPath);
     1956    }
    19541957
    19551958    /*
  • trunk/src/VBox/Main/src-server/CertificateImpl.cpp

    r60331 r60334  
    2222
    2323#include "ProgressImpl.h"
    24 #include "ApplianceImpl.h"
    25 #include "ApplianceImplPrivate.h"
    2624#include "CertificateImpl.h"
    2725#include "AutoCaller.h"
     
    8684}
    8785
    88 HRESULT Certificate::init(Appliance* appliance)
    89 {
    90     HRESULT rc = S_OK;
    91     LogFlowThisFuncEnter();
    92 
    93     /* Enclose the state transition NotReady->InInit->Ready */
    94     AutoInitSpan autoInitSpan(this);
    95     AssertReturn(autoInitSpan.isOk(), E_FAIL);
    96     if(appliance!=NULL)
    97     {
    98         LogFlowThisFunc(("m_appliance: %d \n", m_appliance));
    99         m_appliance = appliance;
    100     }
    101     else
    102         rc = E_FAIL;
    103 
    104     /* Confirm a successful initialization when it's the case */
    105     if (SUCCEEDED(rc))
    106         autoInitSpan.setSucceeded();
    107 
    108     LogFlowThisFunc(("rc=%Rhrc\n", rc));
    109     LogFlowThisFuncLeave();
    110 
    111     return rc;
    112 }
    113 
    11486/**
    11587 * Initializes a certificate instance.
     
    12496    LogFlowThisFuncEnter();
    12597
     98    AutoInitSpan autoInitSpan(this);
     99    AssertReturn(autoInitSpan.isOk(), E_FAIL);
     100
    126101    mData = new Data();
    127102    mData->m.allocate();
     
    132107        mData->m->fValidX509 = true;
    133108        mData->m->fTrusted  = a_fTrusted;
     109        autoInitSpan.setSucceeded();
    134110    }
    135111    else
    136112        rc = Global::vboxStatusCodeToCOM(vrc);
    137113
    138     LogFlowThisFunc(("rc=%Rhrc\n", rc));
    139     LogFlowThisFuncLeave();
    140 
     114    LogFlowThisFunc(("returns rc=%Rhrc\n", rc));
    141115    return rc;
    142116}
     
    164138
    165139    Assert(mData->m->fValidX509);
    166     /* version 1 has value 0, so +1.*/
    167     *aVersionNumber = (CertificateVersion_T)(mData->m->X509.TbsCertificate.T0.Version.uValue.u + 1);
    168 
     140    switch (mData->m->X509.TbsCertificate.T0.Version.uValue.u)
     141    {
     142        case RTCRX509TBSCERTIFICATE_V1: *aVersionNumber = (CertificateVersion_T)CertificateVersion_V1; break;
     143        case RTCRX509TBSCERTIFICATE_V2: *aVersionNumber = (CertificateVersion_T)CertificateVersion_V2; break;
     144        case RTCRX509TBSCERTIFICATE_V3: *aVersionNumber = (CertificateVersion_T)CertificateVersion_V3; break;
     145        default: AssertFailed();        *aVersionNumber = (CertificateVersion_T)CertificateVersion_Unknown; break;
     146    }
    169147    return S_OK;
    170148}
     
    421399    NOREF(aResult);
    422400    return setError(E_FAIL, "Unknown item %u", aWhat);
    423 }
    424 
    425 /**
    426  * Private method implementation.
    427  * @param aPresence
    428  * @return aPresence
    429  */
    430 HRESULT Certificate::getPresence(BOOL *aPresence)
    431 {
    432     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    433 
    434     *aPresence = m_appliance->m->fSignerCertLoaded;
    435 
    436     return S_OK;
    437 }
    438 
    439 /**
    440  * Private method implementation.
    441  * @param aVerified
    442  * @return aVerified
    443  */
    444 HRESULT Certificate::getVerified(BOOL *aVerified)
    445 {
    446     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    447 
    448     *aVerified = (m_appliance->m->pbSignedDigest &&
    449                   m_appliance->m->fCertificateValid &&
    450                   m_appliance->m->fCertificateValidTime) ? true:false;
    451 
    452     return S_OK;
    453401}
    454402
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette