- Timestamp:
- Apr 5, 2016 11:37:57 PM (9 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportAppPageBasic2.cpp
r60339 r60341 40 40 41 41 /********************************************************************************************************************************* 42 * Class UIApplianceCertificateViewer implementation.*42 * Class UIApplianceCertificateViewer. * 43 43 *********************************************************************************************************************************/ 44 44 45 UIAppliance CertificateViewer::UIApplianceCertificateViewer(QWidget *pParent, const CCertificate &certificate)45 UIApplianceUnverifiedCertificate::UIApplianceUnverifiedCertificate(QWidget *pParent, const CCertificate &certificate) 46 46 : QIWithRetranslateUI<QIDialog>(pParent) 47 47 , m_certificate(certificate) 48 , m_pTextLabel( 0)49 , m_pTextBrowser( 0)48 , m_pTextLabel(NULL) 49 , m_pTextBrowser(NULL) 50 50 { 51 51 /* Prepare: */ … … 53 53 } 54 54 55 void UIAppliance CertificateViewer::prepare()55 void UIApplianceUnverifiedCertificate::prepare() 56 56 { 57 57 /* Create layout: */ … … 68 68 pLayout->addWidget(m_pTextLabel); 69 69 } 70 70 71 /* Create text-browser: */ 71 72 m_pTextBrowser = new QTextBrowser; … … 77 78 pLayout->addWidget(m_pTextBrowser); 78 79 } 80 79 81 /* Create button-box: */ 80 82 QIDialogButtonBox *pButtonBox = new QIDialogButtonBox; … … 82 84 { 83 85 /* Configure button-box: */ 84 pButtonBox->setStandardButtons(QDialogButtonBox::Ok); 85 pButtonBox->button(QDialogButtonBox::Ok)->setShortcut(Qt::Key_Enter); 86 pButtonBox->setStandardButtons(QDialogButtonBox::Yes | QDialogButtonBox::No); 87 88 pButtonBox->button(QDialogButtonBox::Yes)->setShortcut(Qt::Key_Enter); 86 89 connect(pButtonBox, SIGNAL(accepted()), this, SLOT(close())); 90 91 //pButtonBox->button(QDialogButtonBox::No)->setShortcut(Qt::Key_Esc); 92 connect(pButtonBox, SIGNAL(rejected()), this, SLOT(close())); 93 87 94 /* Add button-box into layout: */ 88 95 pLayout->addWidget(pButtonBox); … … 93 100 } 94 101 95 void UIAppliance CertificateViewer::retranslateUi()102 void UIApplianceUnverifiedCertificate::retranslateUi() 96 103 { 97 104 /* Translate dialog title: */ 98 setWindowTitle(tr("Certificate Information")); 105 setWindowTitle(tr("Unverifiable Certificate! Continue?")); 106 99 107 /* Translate text-label caption: */ 100 m_pTextLabel->setText(tr("<b>The X509 certificate exists but hasn't been verified or trusted. " 101 "You can proceed with the importing but should understand the risks. " 102 "If you are not sure - just stop here and interrupt the importing process.</b>")); 108 if (m_certificate.GetSelfSigned()) 109 m_pTextLabel->setText(tr("<b>The appliance is signed by an unverified self signed certificate issued by '%1'. " 110 "We recommend to only proceed with the importing if you are sure you should trust this entity.</b>" 111 ).arg(m_certificate.GetFriendlyName())); 112 else 113 m_pTextLabel->setText(tr("<b>The appliance is signed by an unverified certificate issued to '%1'. " 114 "We recommend to only proceed with the importing if you are sure you should trust this entity.</b>" 115 ).arg(m_certificate.GetFriendlyName())); 116 103 117 /* Translate text-browser contents: */ 104 118 QStringList info; 105 KCertificateVersion ver = (m_certificate.GetVersionNumber()); 106 info << tr("Certificate Version Number: %1").arg(ver); 107 info << tr("Certificate Serial Number: 0x%1").arg(m_certificate.GetSerialNumber()); 108 info << tr("Certificate Authority (CA): %1").arg(m_certificate.GetCertificateAuthority() ? tr("True") : tr("False")); 109 info << tr("Certificate Self-Signed: %1").arg(m_certificate.GetSelfSigned() ? tr("True") : tr("False")); 110 info << tr("Certificate Trusted: %1").arg(m_certificate.GetTrusted() ? tr("True") : tr("False")); 111 info << tr("Certificate Issuer: %1").arg(QStringList(m_certificate.GetIssuerName().toList()).join(", ")); 112 info << tr("Certificate Subject: %1").arg(QStringList(m_certificate.GetSubjectName().toList()).join(", ")); 113 info << tr("Certificate Public Algorithm: %1").arg(m_certificate.GetPublicKeyAlgorithm()); 114 info << tr("Certificate Signature Algorithm: %1").arg(m_certificate.GetSignatureAlgorithmName()); 115 info << tr("Certificate Signature Algorithm OID: %1").arg(m_certificate.GetSignatureAlgorithmOID()); 116 info << tr("Certificate Validity Period Not Before: %1").arg(m_certificate.GetValidityPeriodNotBefore()); 117 info << tr("Certificate Validity Period Not After: %1").arg(m_certificate.GetValidityPeriodNotAfter()); 118 m_pTextBrowser->setText(info.join("<br><br>")); 119 KCertificateVersion ver = m_certificate.GetVersionNumber(); 120 info << tr("Issuer: %1").arg(QStringList(m_certificate.GetIssuerName().toList()).join(", ")); 121 info << tr("Subject: %1").arg(QStringList(m_certificate.GetSubjectName().toList()).join(", ")); 122 info << tr("Not Valid Before: %1").arg(m_certificate.GetValidityPeriodNotBefore()); 123 info << tr("Not Valid After: %1").arg(m_certificate.GetValidityPeriodNotAfter()); 124 info << tr("Serial Number: %1").arg(m_certificate.GetSerialNumber()); 125 info << tr("Self-Signed: %1").arg(m_certificate.GetSelfSigned() ? tr("True") : tr("False")); 126 info << tr("Authority (CA): %1").arg(m_certificate.GetCertificateAuthority() ? tr("True") : tr("False")); 127 //info << tr("Trusted: %1").arg(m_certificate.GetTrusted() ? tr("True") : tr("False")); - no, that's why we're here 128 info << tr("Public Algorithm: %1 (%1)").arg(m_certificate.GetPublicKeyAlgorithm()).arg(m_certificate.GetPublicKeyAlgorithmOID()); 129 info << tr("Signature Algorithm: %1 (%1)").arg(m_certificate.GetSignatureAlgorithmName()).arg(m_certificate.GetSignatureAlgorithmOID()); 130 info << tr("X.509 Version Number: %1").arg(ver); 131 m_pTextBrowser->setText(info.join("<br>")); 119 132 } 120 133 … … 134 147 135 148 UIWizardImportAppPageBasic2::UIWizardImportAppPageBasic2(const QString &strFileName) 149 : m_enmCertText(kCertText_Uninitialized) 136 150 { 137 151 /* Create widgets: */ … … 144 158 m_pApplianceWidget->setFile(strFileName); 145 159 } 160 m_pCertLabel = new QLabel("<cert label>", this); 146 161 pMainLayout->addWidget(m_pLabel); 147 162 pMainLayout->addWidget(m_pApplianceWidget); 163 pMainLayout->addWidget(m_pCertLabel); 148 164 } 149 165 … … 164 180 "You can change many of the properties shown by double-clicking " 165 181 "on the items and disable others using the check boxes below.")); 182 switch (m_enmCertText) 183 { 184 case kCertText_Unsigned: 185 m_pCertLabel->setText(UIWizardImportApp::tr("Appliance is not signed")); 186 break; 187 case kCertText_IssuedTrusted: 188 m_pCertLabel->setText(UIWizardImportApp::tr("Appliance signed by %1 (trusted)").arg(m_strSignedBy)); 189 break; 190 case kCertText_IssuedExpired: 191 m_pCertLabel->setText(UIWizardImportApp::tr("Appliance signed by %1 (expired!)").arg(m_strSignedBy)); 192 break; 193 case kCertText_IssuedUnverified: 194 m_pCertLabel->setText(UIWizardImportApp::tr("Unverified signature by %1!").arg(m_strSignedBy)); 195 break; 196 case kCertText_SelfSignedTrusted: 197 m_pCertLabel->setText(UIWizardImportApp::tr("Self signed by %1 (trusted)").arg(m_strSignedBy)); 198 break; 199 case kCertText_SelfSignedExpired: 200 m_pCertLabel->setText(UIWizardImportApp::tr("Self signed by %1 (expired!)").arg(m_strSignedBy)); 201 break; 202 case kCertText_SelfSignedUnverified: 203 m_pCertLabel->setText(UIWizardImportApp::tr("Unverified self signed signature by %1!").arg(m_strSignedBy)); 204 break; 205 default: 206 AssertFailed(); 207 case kCertText_Uninitialized: 208 m_pCertLabel->setText("<uninitialized page>"); 209 break; 210 } 166 211 } 167 212 168 213 void UIWizardImportAppPageBasic2::initializePage() 169 214 { 170 /* Translate page: */171 retranslateUi();172 173 215 /* Acquire appliance and certificate: */ 174 216 CAppliance *pAppliance = m_pApplianceWidget->appliance(); 175 217 CCertificate certificate = pAppliance->GetCertificate(); 176 if (!certificate.isNull()) 177 { 178 if(!certificate.GetTrusted() || certificate.GetSelfSigned()) 179 { 180 /* Create certificate viewer to notify user about it is not verified: */ 181 QPointer<UIApplianceCertificateViewer> pDialog = 182 new UIApplianceCertificateViewer(this, certificate); 183 AssertPtrReturnVoid(pDialog.data()); 184 { 185 /* Show viewer in modal mode: */ 186 pDialog->exec(); 187 /* Leave if destroyed prematurely: */ 188 if (!pDialog) 189 return; 190 /* Delete viewer finally: */ 191 delete pDialog; 192 pDialog = 0; 193 } 194 } 195 } 218 if (certificate.isNull()) 219 m_enmCertText = kCertText_Unsigned; 196 220 else 197 221 { 198 /* Translate page: */ 199 retranslateUi(); 200 /* Create dialog: */ 201 QDialog *pDialog = new QDialog(this, Qt::Dialog); 202 AssertPtrReturnVoid(pDialog); 203 /* Create layout: */ 204 QVBoxLayout *pLayout = new QVBoxLayout(pDialog); 205 AssertPtrReturnVoid(pLayout); 206 { 207 /* Prepare dialog: */ 208 pDialog->resize(500, 100); 209 /*todo: show an error message and prohibit OVF import */ 210 { 211 /* Create text-label: */ 212 QLabel *m_pTextLabel = new QLabel; 213 AssertPtrReturnVoid(m_pTextLabel); 214 { 215 /* Configure text-label: */ 216 m_pTextLabel->setWordWrap(true); 217 m_pTextLabel->setText(tr("<b>The X509 certificate exists but hasn't been verified." 218 "You should stop here and interrupt the importing process.</b>")); 219 /* Add text-label into layout: */ 220 pLayout->addWidget(m_pTextLabel); 221 } 222 223 pLayout->addStretch(); 224 225 /* Create button-box: */ 226 QIDialogButtonBox *pButtonBox = new QIDialogButtonBox; 227 AssertPtrReturnVoid(pButtonBox); 228 { 229 /* Configure button-box: */ 230 pButtonBox->setStandardButtons(QDialogButtonBox::Ok); 231 pButtonBox->button(QDialogButtonBox::Ok)->setShortcut(Qt::Key_Enter); 232 connect(pButtonBox, SIGNAL(accepted()), this, SLOT(close())); 233 /* Add button-box into layout: */ 234 pLayout->addWidget(pButtonBox); 235 } 236 } 237 /* Show dialog in modal mode: */ 222 /* Pick a 'signed-by' name. */ 223 m_strSignedBy = certificate.GetFriendlyName(); 224 225 /* 226 * If trusted, just select the right message. 227 */ 228 if (certificate.GetTrusted()) 229 { 230 if (certificate.GetSelfSigned()) 231 m_enmCertText = !certificate.GetExpired() ? kCertText_SelfSignedTrusted : kCertText_SelfSignedExpired; 232 else 233 m_enmCertText = !certificate.GetExpired() ? kCertText_IssuedTrusted : kCertText_IssuedExpired; 234 } 235 else 236 { 237 /* 238 * Not trusted! Must ask the user whether to continue in this case. 239 */ 240 m_enmCertText = !certificate.GetExpired() ? kCertText_SelfSignedUnverified : kCertText_SelfSignedUnverified; 241 retranslateUi(); 242 243 /* Instantiate the dialog: */ 244 QPointer<UIApplianceUnverifiedCertificate> pDialog = new UIApplianceUnverifiedCertificate(this, certificate); 245 AssertPtrReturnVoid(pDialog.data()); 246 247 /* Show viewer in modal mode: */ 238 248 pDialog->exec(); 239 /* Delete dialog finally: */ 249 250 /** @todo 251 * 252 * Must dismiss the wizard if dialog was rejected! 253 * Must dismiss the wizard if dialog was rejected! 254 * Must dismiss the wizard if dialog was rejected! 255 * 256 * Someone with clue try figure out how. 257 * 258 */ 259 260 /* Leave if destroyed prematurely: */ 261 if (!pDialog) 262 return; /** @todo r=bird: what happened to this dialog in that case?? */ 263 264 /* Delete viewer finally: */ 240 265 delete pDialog; 241 pDialog = 0;266 pDialog = NULL; 242 267 } 243 268 } 269 270 /* Translate page: */ 271 retranslateUi(); 244 272 } 245 273 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportAppPageBasic2.h
r60276 r60341 16 16 */ 17 17 18 #ifndef __ UIWizardImportAppPageBasic2_h__19 #define __ UIWizardImportAppPageBasic2_h__18 #ifndef ___UIWizardImportAppPageBasic2_h___ 19 #define ___UIWizardImportAppPageBasic2_h___ 20 20 21 21 /* GUI includes: */ … … 33 33 34 34 35 /** QIDialog extension providing user with the information 36 * about the appliance certificate which validation failed. */ 37 class UIApplianceCertificateViewer : public QIWithRetranslateUI<QIDialog> 38 { 39 Q_OBJECT; 40 41 public: 42 43 /** Constructs appliance @a certificate viewer for passed @a pParent. */ 44 UIApplianceCertificateViewer(QWidget *pParent, const CCertificate &certificate); 45 46 protected: 47 48 /** Prepares all. */ 49 void prepare(); 50 51 /** Handles translation event. */ 52 virtual void retranslateUi() /* override */; 53 54 private: 55 56 /** Holds the certificate reference. */ 57 const CCertificate &m_certificate; 58 59 /** Holds the text-label instance. */ 60 QLabel *m_pTextLabel; 61 /** Holds the text-browser instance. */ 62 QTextBrowser *m_pTextBrowser; 63 }; 64 65 66 /* 2nd page of the Import Appliance wizard (base part): */ 35 /** 2nd page of the Import Appliance wizard (base part): */ 67 36 class UIWizardImportAppPage2 : public UIWizardPageBase 68 37 { … … 79 48 }; 80 49 81 /* 2nd page of the Import Appliance wizard (basic extension): */50 /** 2nd page of the Import Appliance wizard (basic extension): */ 82 51 class UIWizardImportAppPageBasic2 : public UIWizardPage, public UIWizardImportAppPage2 83 52 { … … 104 73 /* Widgets: */ 105 74 QIRichTextLabel *m_pLabel; 75 QLabel *m_pCertLabel; /**< Signature/certificate info label. */ 76 enum { 77 kCertText_Uninitialized = 0, kCertText_Unsigned, 78 kCertText_IssuedTrusted, kCertText_IssuedExpired, kCertText_IssuedUnverified, 79 kCertText_SelfSignedTrusted, kCertText_SelfSignedExpired, kCertText_SelfSignedUnverified 80 } m_enmCertText; 81 QString m_strSignedBy; 106 82 }; 107 83 108 #endif /* __UIWizardImportAppPageBasic2_h__ */ 84 /** 85 * Dialog for asking consent to continue with unverifiable certificate. 86 */ 87 class UIApplianceUnverifiedCertificate : public QIWithRetranslateUI<QIDialog> 88 { 89 Q_OBJECT; 109 90 91 public: 92 /** Constructs appliance @a certificate viewer for passed @a pParent. */ 93 UIApplianceUnverifiedCertificate(QWidget *pParent, const CCertificate &certificate); 94 95 protected: 96 /** Prepares all. */ 97 void prepare(); 98 99 /** Handles translation event. */ 100 virtual void retranslateUi() /* override */; 101 102 private: 103 /** Holds the certificate reference. */ 104 const CCertificate &m_certificate; 105 106 /** Holds the text-label instance. */ 107 QLabel *m_pTextLabel; 108 /** Holds the text-browser instance. */ 109 QTextBrowser *m_pTextBrowser; 110 }; 111 112 113 #endif /* !___UIWizardImportAppPageBasic2_h___ */ 114 -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r60334 r60341 2999 2999 <interface 3000 3000 name="ICertificate" extends="$unknown" 3001 uuid=" c85f71ef-dd7f-4b9c-aa58-5c186a95d7f9"3001 uuid="392f1de4-80e1-4a8a-93a1-67c5f92a838a" 3002 3002 wsmap="managed" 3003 3003 reservedAttributes="12" reservedMethods="2" … … 3027 3027 <desc>Subject name. Same format as issuerName.</desc> 3028 3028 </attribute> 3029 <attribute name="friendlyName" type="wstring" readonly="yes"> 3030 <desc>Friendly subject name or similar.</desc> 3031 </attribute> 3029 3032 <attribute name="validityPeriodNotBefore" type="wstring" readonly="yes"> 3030 3033 <desc>Certificate not valid before ISO time stamp.</desc> … … 3065 3068 <desc>Set if self signed certificate.</desc> 3066 3069 </attribute> 3070 3071 <!-- The following is subject to the parent object views. --> 3067 3072 <attribute name="trusted" type="boolean" readonly="yes"> 3068 <desc>Set if the certificate is trusted.</desc> 3069 </attribute> 3073 <desc>Set if the certificate is trusted (by the parent object).</desc> 3074 </attribute> 3075 <attribute name="expired" type="boolean" readonly="yes"> <!-- isCurrentlyExpired is clearer than isCurrentlyValid. --> 3076 <desc>Set if the certificate has expired (relevant to the parent object)/</desc> 3077 </attribute> 3078 3079 <method name="isCurrentlyExpired"> 3080 <desc> 3081 Tests if the certificate has expired at the present time according to 3082 the X.509 validity of the certificate.</desc> 3083 <param name="result" type="boolean" dir="return" /> 3084 </method> 3070 3085 3071 3086 <method name="queryInfo"> -
trunk/src/VBox/Main/include/CertificateImpl.h
r60334 r60341 36 36 DECLARE_EMPTY_CTOR_DTOR(Certificate) 37 37 38 HRESULT initCertificate(PCRTCRX509CERTIFICATE a_pCert, bool a_fTrusted );38 HRESULT initCertificate(PCRTCRX509CERTIFICATE a_pCert, bool a_fTrusted, bool a_fExpired); 39 39 void uninit(); 40 40 … … 52 52 HRESULT getIssuerName(std::vector<com::Utf8Str> &aIssuerName); 53 53 HRESULT getSubjectName(std::vector<com::Utf8Str> &aSubjectName); 54 HRESULT getFriendlyName(com::Utf8Str &aFriendlyName); 54 55 HRESULT getValidityPeriodNotBefore(com::Utf8Str &aValidityPeriodNotBefore); 55 56 HRESULT getValidityPeriodNotAfter(com::Utf8Str &aValidityPeriodNotAfter); … … 63 64 HRESULT getSelfSigned(BOOL *aSelfSigned); 64 65 HRESULT getTrusted(BOOL *aTrusted); 66 HRESULT getExpired(BOOL *aExpired); 65 67 // wrapped ICertificate methods 68 HRESULT isCurrentlyExpired(BOOL *aResult); 66 69 HRESULT queryInfo(LONG aWhat, com::Utf8Str &aResult); 67 70 -
trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp
r60334 r60341 1808 1808 * is acceptible. But, first make sure it makes internal sense. 1809 1809 */ 1810 m->fCertificateMissingPath = false; /** @todo need to check if the certificate is trusted by the system! */1810 m->fCertificateMissingPath = true; /** @todo need to check if the certificate is trusted by the system! */ 1811 1811 vrc = RTCrX509Certificate_VerifySignatureSelfSigned(&m->SignerCert, RTErrInfoInitStatic(&StaticErrInfo)); 1812 1812 if (RT_SUCCESS(vrc)) … … 1953 1953 { 1954 1954 m->ptrCertificateInfo.createObject(); 1955 m->ptrCertificateInfo->initCertificate(&m->SignerCert, m->fCertificateValid && !m->fCertificateMissingPath); 1955 m->ptrCertificateInfo->initCertificate(&m->SignerCert, 1956 m->fCertificateValid && !m->fCertificateMissingPath, 1957 !m->fCertificateValidTime); 1956 1958 } 1957 1959 -
trunk/src/VBox/Main/src-server/CertificateImpl.cpp
r60334 r60341 33 33 CertificateData() 34 34 : fTrusted(false) 35 , fExpired(false) 35 36 , fValidX509(false) 36 37 { … … 50 51 /** Whether the certificate is trusted. */ 51 52 bool fTrusted; 53 /** Whether the certificate is trusted. */ 54 bool fExpired; 52 55 /** Valid data in mX509. */ 53 56 bool fValidX509; … … 90 93 * @param a_pCert The certificate. 91 94 * @param a_fTrusted Whether the caller trusts the certificate or not. 92 */ 93 HRESULT Certificate::initCertificate(PCRTCRX509CERTIFICATE a_pCert, bool a_fTrusted) 95 * @param a_fExpired Whether the caller consideres the certificate to be 96 * expired. 97 */ 98 HRESULT Certificate::initCertificate(PCRTCRX509CERTIFICATE a_pCert, bool a_fTrusted, bool a_fExpired) 94 99 { 95 100 HRESULT rc = S_OK; … … 106 111 { 107 112 mData->m->fValidX509 = true; 108 mData->m->fTrusted = a_fTrusted; 113 mData->m->fTrusted = a_fTrusted; 114 mData->m->fExpired = a_fExpired; 109 115 autoInitSpan.setSucceeded(); 110 116 } … … 127 133 mData = NULL; 128 134 } 135 136 137 /** @name wrapped ICertificate properties 138 * @{ 139 */ 129 140 130 141 /** … … 223 234 } 224 235 236 HRESULT Certificate::getFriendlyName(com::Utf8Str &aFriendlyName) 237 { 238 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 239 240 Assert(mData->m->fValidX509); 241 242 PCRTCRX509NAME pName = &mData->m->X509.TbsCertificate.Subject; 243 244 /* 245 * Enumerate the subject name and pick interesting attributes we can use to 246 * form a name more friendly than the RTCrX509Name_FormatAsString output. 247 */ 248 const char *pszOrg = NULL; 249 const char *pszOrgUnit = NULL; 250 const char *pszGivenName = NULL; 251 const char *pszSurname = NULL; 252 const char *pszEmail = NULL; 253 for (uint32_t i = 0; i < pName->cItems; i++) 254 { 255 PCRTCRX509RELATIVEDISTINGUISHEDNAME pRdn = &pName->paItems[i]; 256 for (uint32_t j = 0; j < pRdn->cItems; j++) 257 { 258 PCRTCRX509ATTRIBUTETYPEANDVALUE pComponent = &pRdn->paItems[j]; 259 AssertContinue(pComponent->Value.enmType == RTASN1TYPE_STRING); 260 261 /* Select interesting components based on the short RDN prefix 262 string (easier to read and write than OIDs, for now). */ 263 const char *pszPrefix = RTCrX509Name_GetShortRdn(&pComponent->Type); 264 if (pszPrefix) 265 { 266 const char *pszUtf8; 267 int vrc = RTAsn1String_QueryUtf8(&pComponent->Value.u.String, &pszUtf8, NULL); 268 if (RT_SUCCESS(vrc) && *pszUtf8) 269 { 270 if (!strcmp(pszPrefix, "Email")) 271 pszEmail = pszUtf8; 272 else if (!strcmp(pszPrefix, "O")) 273 pszOrg = pszUtf8; 274 else if (!strcmp(pszPrefix, "OU")) 275 pszOrgUnit = pszUtf8; 276 else if (!strcmp(pszPrefix, "S")) 277 pszSurname = pszUtf8; 278 else if (!strcmp(pszPrefix, "G")) 279 pszGivenName = pszUtf8; 280 } 281 } 282 } 283 } 284 285 if (pszGivenName && pszSurname) 286 { 287 if (pszEmail) 288 aFriendlyName = Utf8StrFmt("%s, %s <%s>", pszSurname, pszGivenName, pszEmail); 289 else if (pszOrg) 290 aFriendlyName = Utf8StrFmt("%s, %s (%s)", pszSurname, pszGivenName, pszOrg); 291 else if (pszOrgUnit) 292 aFriendlyName = Utf8StrFmt("%s, %s (%s)", pszSurname, pszGivenName, pszOrgUnit); 293 else 294 aFriendlyName = Utf8StrFmt("%s, %s", pszSurname, pszGivenName); 295 } 296 else if (pszOrg && pszOrgUnit) 297 aFriendlyName = Utf8StrFmt("%s, %s", pszOrg, pszOrgUnit); 298 else if (pszOrg) 299 aFriendlyName = Utf8StrFmt("%s", pszOrg); 300 else if (pszOrgUnit) 301 aFriendlyName = Utf8StrFmt("%s", pszOrgUnit); 302 else 303 { 304 /* 305 * Fall back on unfriendly but accurate. 306 */ 307 char szTmp[_8K]; 308 RT_ZERO(szTmp); 309 RTCrX509Name_FormatAsString(pName, szTmp, sizeof(szTmp) - 1, NULL); 310 aFriendlyName = szTmp; 311 } 312 313 return S_OK; 314 } 315 225 316 /** 226 317 * Private method implementation. … … 382 473 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 383 474 475 Assert(mData->m->fValidX509); 384 476 *aTrusted = mData->m->fTrusted; 385 477 … … 387 479 } 388 480 389 /** 390 * Private method implementation. 391 * @param aWhat 392 * @param aResult 393 * @return 394 */ 481 HRESULT Certificate::getExpired(BOOL *aExpired) 482 { 483 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 484 Assert(mData->m->fValidX509); 485 *aExpired = mData->m->fExpired; 486 return S_OK; 487 } 488 489 /** @} */ 490 491 /** @name Wrapped ICertificate methods 492 * @{ 493 */ 494 495 HRESULT Certificate::isCurrentlyExpired(BOOL *aResult) 496 { 497 AssertReturnStmt(mData->m->fValidX509, *aResult = TRUE, E_UNEXPECTED); 498 RTTIMESPEC Now; 499 *aResult = RTCrX509Validity_IsValidAtTimeSpec(&mData->m->X509.TbsCertificate.Validity, RTTimeNow(&Now)) ? FALSE : TRUE; 500 return S_OK; 501 } 502 395 503 HRESULT Certificate::queryInfo(LONG aWhat, com::Utf8Str &aResult) 396 504 { … … 400 508 return setError(E_FAIL, "Unknown item %u", aWhat); 401 509 } 510 511 /** @} */ 512 513 514 /** @name Methods extracting COM data from the certificate object 515 * @{ 516 */ 402 517 403 518 HRESULT Certificate::i_getAlgorithmName(PCRTCRX509ALGORITHMIDENTIFIER a_pAlgId, com::Utf8Str &a_rReturn) … … 506 621 } 507 622 508 623 /** @} */ 624
Note:
See TracChangeset
for help on using the changeset viewer.