mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-25 22:54:57 +02:00
Build fix for FreeBSD
This commit is contained in:
parent
5abc3cfe55
commit
97cf93089b
@ -400,14 +400,14 @@ String CertificateToString(const shared_ptr<X509>& cert)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
String PBKDF2_SHA512(const String& password, const String& salt, int iterations)
|
String PBKDF2_SHA1(const String& password, const String& salt, int iterations)
|
||||||
{
|
{
|
||||||
unsigned char digest[SHA512_DIGEST_LENGTH];
|
unsigned char digest[SHA_DIGEST_LENGTH];
|
||||||
PKCS5_PBKDF2_HMAC(password.CStr(), password.GetLength(), reinterpret_cast<const unsigned char *>(salt.CStr()), salt.GetLength(),
|
PKCS5_PBKDF2_HMAC_SHA1(password.CStr(), password.GetLength(), reinterpret_cast<const unsigned char *>(salt.CStr()), salt.GetLength(),
|
||||||
iterations, EVP_sha512(), sizeof(digest), digest);
|
iterations, sizeof(digest), digest);
|
||||||
|
|
||||||
char output[SHA512_DIGEST_LENGTH*2+1];
|
char output[SHA_DIGEST_LENGTH*2+1];
|
||||||
for (int i = 0; i < 32; i++)
|
for (int i = 0; i < SHA_DIGEST_LENGTH; i++)
|
||||||
sprintf(output + 2 * i, "%02x", digest[i]);
|
sprintf(output + 2 * i, "%02x", digest[i]);
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include <openssl/comp.h>
|
#include <openssl/comp.h>
|
||||||
#include <openssl/sha.h>
|
#include <openssl/sha.h>
|
||||||
#include <openssl/x509v3.h>
|
#include <openssl/x509v3.h>
|
||||||
|
#include <openssl/evp.h>
|
||||||
|
|
||||||
namespace icinga
|
namespace icinga
|
||||||
{
|
{
|
||||||
@ -44,7 +45,7 @@ shared_ptr<X509> I2_BASE_API CreateCert(EVP_PKEY *pubkey, X509_NAME *subject, X5
|
|||||||
String I2_BASE_API GetIcingaCADir(void);
|
String I2_BASE_API GetIcingaCADir(void);
|
||||||
String I2_BASE_API CertificateToString(const shared_ptr<X509>& cert);
|
String I2_BASE_API CertificateToString(const shared_ptr<X509>& cert);
|
||||||
shared_ptr<X509> I2_BASE_API CreateCertIcingaCA(EVP_PKEY *pubkey, X509_NAME *subject);
|
shared_ptr<X509> I2_BASE_API CreateCertIcingaCA(EVP_PKEY *pubkey, X509_NAME *subject);
|
||||||
String I2_BASE_API PBKDF2_SHA512(const String& password, const String& salt, int iterations);
|
String I2_BASE_API PBKDF2_SHA1(const String& password, const String& salt, int iterations);
|
||||||
String I2_BASE_API SHA256(const String& s);
|
String I2_BASE_API SHA256(const String& s);
|
||||||
|
|
||||||
class I2_BASE_API openssl_error : virtual public std::exception, virtual public boost::exception { };
|
class I2_BASE_API openssl_error : virtual public std::exception, virtual public boost::exception { };
|
||||||
|
@ -68,7 +68,7 @@ int PKITicketCommand::Run(const boost::program_options::variables_map& vm, const
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << PBKDF2_SHA512(vm["cn"].as<std::string>(), vm["salt"].as<std::string>(), 50000) << std::endl;
|
std::cout << PBKDF2_SHA1(vm["cn"].as<std::string>(), vm["salt"].as<std::string>(), 50000) << std::endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -239,7 +239,7 @@ Value RequestCertificateHandler(const MessageOrigin& origin, const Dictionary::P
|
|||||||
}
|
}
|
||||||
|
|
||||||
String ticket = params->Get("ticket");
|
String ticket = params->Get("ticket");
|
||||||
String realTicket = PBKDF2_SHA512(origin.FromClient->GetIdentity(), salt, 50000);
|
String realTicket = PBKDF2_SHA1(origin.FromClient->GetIdentity(), salt, 50000);
|
||||||
|
|
||||||
if (ticket != realTicket) {
|
if (ticket != realTicket) {
|
||||||
result->Set("error", "Invalid ticket.");
|
result->Set("error", "Invalid ticket.");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user