Changeset 50832 in vbox
- Timestamp:
- Mar 21, 2014 6:08:32 AM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 92911
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/err.h
r50155 r50832 1879 1879 /** @} */ 1880 1880 1881 /** @name RTX509 status codes 1882 * @{ */ 1883 /** Error during reading a certificate in PEM format from BIO */ 1884 #define VERR_READING_CERT_FROM_BIO (-22800) 1885 /** Error extract a public key from the certificate */ 1886 #define VERR_EXTRACT_PUBKEY_FROM_CERT (-22801) 1887 /** Error extract RSA from the public key */ 1888 #define VERR_EXTRACT_RSA_FROM_PUBLIC_KEY (-22802) 1889 /** Error the signature verification */ 1890 #define VERR_RSA_VERIFICATION_FUILURE (-22803) 1891 /** Error basic constraints were not found */ 1892 #define VERR_NO_BASIC_CONSTARAINTS (-22804) 1893 /** Error getting extensions from the certificate */ 1894 #define VERR_GETTING_EXTENSION_FROM_CERT (-22805) 1895 /** Error getting a data from the extension */ 1896 #define VERR_GETTING_DATA_FROM_EXTENSION (-22806) 1897 /** Error print out an extension to BIO */ 1898 #define VERR_PRINT_EXTENSION_TO_BIO (-22807) 1899 /** Error X509 certificate verification */ 1900 #define VERR_X509_CERTIFICATE_VERIFICATION_FAILURE (-22808) 1901 /** Error X509 certificate isn't self signed */ 1902 #define VERR_NOT_SELFSIGNED_X509_CERTIFICATE (-22809) 1903 /** @} */ 1881 1904 1882 1905 /* SED-END */ -
trunk/include/iprt/mangling.h
r50792 r50832 1199 1199 # define RTReqRetain RT_MANGLER(RTReqRetain) 1200 1200 # define RTReqWait RT_MANGLER(RTReqWait) 1201 # define RTRSAVerify RT_MANGLER(RTRSAVerify) 1201 1202 # define RTReqGetStatus RT_MANGLER(RTReqGetStatus) 1202 1203 # define RTS3BucketsDestroy RT_MANGLER(RTS3BucketsDestroy) … … 1882 1883 # define RTVfsUtilDummyPollOne RT_MANGLER(RTVfsUtilDummyPollOne) 1883 1884 # define RTVfsUtilPumpIoStreams RT_MANGLER(RTVfsUtilPumpIoStreams) 1885 # define RTX509PrepareOpenSSL RT_MANGLER(RTX509PrepareOpenSSL) 1886 # define RTX509CertificateVerify RT_MANGLER(RTX509CertificateVerify) 1887 # define RTX509GetErrorDescription RT_MANGLER(RTX509GetErrorDescription) 1884 1888 # define RTZipBlockCompress RT_MANGLER(RTZipBlockCompress) 1885 1889 # define RTZipBlockDecompress RT_MANGLER(RTZipBlockDecompress) -
trunk/src/VBox/Main/Makefile.kmk
r50686 r50832 318 318 $(PATH_STAGE_LIB)/SSMStandalone$(VBOX_SUFF_LIB) \ 319 319 $(LIB_DDU) 320 VBoxSVC_SDKS = VBOX_LIBPNG VBOX_ZLIB 320 321 VBoxSVC_SDKS = VBOX_LIBPNG VBOX_ZLIB VBOX_OPENSSL 321 322 VBoxSVC_LIBS.solaris = \ 322 323 adm \ -
trunk/src/VBox/Main/include/ApplianceImpl.h
r50444 r50832 181 181 PSHASTORAGE pStorage); 182 182 HRESULT i_verifyManifestFile(const Utf8Str &strFile, ImportStack &stack, void *pvBuf, size_t cbSize); 183 184 HRESULT i_verifyCertificateFile(void *pvBuf, size_t cbSize, PSHASTORAGE pStorage); 183 185 184 186 void i_convertDiskAttachmentValues(const ovf::HardDiskController &hdc, -
trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp
r50355 r50832 47 47 #include <VBox/settings.h> 48 48 49 #include <iprt/x509.h> 49 50 #include <set> 50 51 … … 1517 1518 1518 1519 /* verify Certificate */ 1520 rc = i_verifyCertificateFile(pvCertBuf, cbCertFile, &storage); 1521 if (FAILED(rc)) throw rc; 1519 1522 } 1520 1523 } … … 1588 1591 void *pvCertBuf = NULL; 1589 1592 Utf8Str OVFfilename; 1593 void *pSignatureRSA = NULL; 1590 1594 1591 1595 writeLock.release(); … … 1693 1697 if (pvCertBuf) 1694 1698 { 1695 /* verify the certificate */ 1699 /* verify the certificate */ 1700 rc = i_verifyCertificateFile(pvCertBuf, cbCertFile, pStorage); 1701 if (FAILED(rc)) throw rc; 1696 1702 } 1697 1703 } … … 1738 1744 if (pvCertBuf) 1739 1745 { 1740 /* verify the certificate */ 1746 /* verify the certificate */ 1747 rc = i_verifyCertificateFile(pvCertBuf, cbCertFile, pStorage); 1748 if (FAILED(rc)) throw rc; 1741 1749 } 1742 1750 } … … 2037 2045 HRESULT Appliance::i_verifyManifestFile(const Utf8Str &strFile, ImportStack &stack, void *pvBuf, size_t cbSize) 2038 2046 { 2047 LogFlowFuncEnter(); 2048 LogFlowFunc(("Appliance %p\n", this)); 2039 2049 HRESULT rc = S_OK; 2040 2050 … … 2064 2074 2065 2075 RTMemFree(paTests); 2066 2076 LogFlowFuncLeave(); 2077 2078 return rc; 2079 } 2080 2081 HRESULT Appliance::i_verifyCertificateFile(void *pvBuf, size_t cbSize, PSHASTORAGE pStorage) 2082 { 2083 LogFlowFuncEnter(); 2084 LogFlowFunc(("Appliance %p\n", this)); 2085 HRESULT rc = S_OK; 2086 2087 int vrc = 0; 2088 RTDIGESTTYPE digestType; 2089 void * pvCertBuf = pvBuf; 2090 size_t cbCertSize = cbSize; 2091 Utf8Str manifestDigest = pStorage->strDigest; 2092 2093 vrc = RTManifestVerifyDigestType(pvCertBuf, cbCertSize, &digestType); 2094 if (RT_FAILURE(vrc)) 2095 { 2096 rc = setError(VBOX_E_FILE_ERROR, tr("Digest type of certificate is unknown")); 2097 } 2098 else 2099 { 2100 RTX509PrepareOpenSSL(); 2101 2102 vrc = RTRSAVerify(pvCertBuf, (unsigned int)cbCertSize, manifestDigest.c_str(), digestType); 2103 if (RT_SUCCESS(vrc)) 2104 { 2105 vrc = RTX509CertificateVerify(pvCertBuf, (unsigned int)cbCertSize); 2106 } 2107 2108 /* After first unsuccessful operation */ 2109 if (RT_FAILURE(vrc)) 2110 { 2111 { 2112 /* first stage for getting possible error code and it's description using native openssl method */ 2113 char* errStrDesc = NULL; 2114 unsigned long errValue = RTX509GetErrorDescription(&errStrDesc); 2115 2116 if(errValue != 0) 2117 { 2118 rc = setError(VBOX_E_FILE_ERROR, tr(errStrDesc)); 2119 LogFlowFunc(("Error during verifying X509 certificate(internal openssl description): %s\n", errStrDesc)); 2120 } 2121 2122 RTMemFree(errStrDesc); 2123 } 2124 2125 { 2126 /* second stage for getting possible error code using our defined errors codes. The original error description 2127 will be replaced by our description */ 2128 2129 Utf8Str errStrDesc; 2130 switch(vrc) 2131 { 2132 case VERR_READING_CERT_FROM_BIO: 2133 errStrDesc = "Error during reading a certificate in PEM format from BIO "; 2134 break; 2135 case VERR_EXTRACT_PUBKEY_FROM_CERT: 2136 errStrDesc = "Error during extraction a public key from the certificate "; 2137 break; 2138 case VERR_EXTRACT_RSA_FROM_PUBLIC_KEY: 2139 errStrDesc = "Error during extraction RSA from the public key "; 2140 break; 2141 case VERR_RSA_VERIFICATION_FUILURE: 2142 errStrDesc = "RSA verification failure "; 2143 break; 2144 case VERR_NO_BASIC_CONSTARAINTS: 2145 errStrDesc = "Basic constraints were not found "; 2146 break; 2147 case VERR_GETTING_EXTENSION_FROM_CERT: 2148 errStrDesc = "Error during getting extensions from the certificate "; 2149 break; 2150 case VERR_GETTING_DATA_FROM_EXTENSION: 2151 errStrDesc = "Error during extraction data from the extension "; 2152 break; 2153 case VERR_PRINT_EXTENSION_TO_BIO: 2154 errStrDesc = "Error during print out an extension to BIO "; 2155 break; 2156 case VERR_X509_CERTIFICATE_VERIFICATION_FAILURE: 2157 errStrDesc = "X509 certificate verification failure "; 2158 break; 2159 case VERR_NOT_SELFSIGNED_X509_CERTIFICATE: 2160 errStrDesc = "Only self signed X509 certificates are supported at moment"; 2161 break; 2162 default: 2163 errStrDesc = "Unknown error during X509 certificate verification"; 2164 } 2165 rc = setError(VBOX_E_FILE_ERROR, tr(errStrDesc.c_str())); 2166 } 2167 } 2168 } 2169 2170 LogFlowFuncLeave(); 2067 2171 return rc; 2068 2172 } -
trunk/src/VBox/Runtime/Makefile.kmk
r50526 r50832 282 282 common/checksum/sha512.cpp \ 283 283 common/checksum/sha512str.cpp \ 284 common/checksum/x509.cpp \ 284 285 common/dbg/dbg.cpp \ 285 286 common/dbg/dbgas.cpp \
Note:
See TracChangeset
for help on using the changeset viewer.