예제 #1
0
파일: SSLContext.cpp 프로젝트: 1Hgm/folly
void SSLContext::loadCertificateFromBufferPEM(folly::StringPiece cert) {
  if (cert.data() == nullptr) {
    throw std::invalid_argument("loadCertificate: <cert> is nullptr");
  }

  ssl::BioUniquePtr bio(BIO_new(BIO_s_mem()));
  if (bio == nullptr) {
    throw std::runtime_error("BIO_new: " + getErrors());
  }

  int written = BIO_write(bio.get(), cert.data(), cert.size());
  if (written <= 0 || static_cast<unsigned>(written) != cert.size()) {
    throw std::runtime_error("BIO_write: " + getErrors());
  }

  ssl::X509UniquePtr x509(
      PEM_read_bio_X509(bio.get(), nullptr, nullptr, nullptr));
  if (x509 == nullptr) {
    throw std::runtime_error("PEM_read_bio_X509: " + getErrors());
  }

  if (SSL_CTX_use_certificate(ctx_, x509.get()) == 0) {
    throw std::runtime_error("SSL_CTX_use_certificate: " + getErrors());
  }
}
예제 #2
0
파일: SSLContext.cpp 프로젝트: 1Hgm/folly
void SSLContext::loadPrivateKeyFromBufferPEM(folly::StringPiece pkey) {
  if (pkey.data() == nullptr) {
    throw std::invalid_argument("loadPrivateKey: <pkey> is nullptr");
  }

  ssl::BioUniquePtr bio(BIO_new(BIO_s_mem()));
  if (bio == nullptr) {
    throw std::runtime_error("BIO_new: " + getErrors());
  }

  int written = BIO_write(bio.get(), pkey.data(), pkey.size());
  if (written <= 0 || static_cast<unsigned>(written) != pkey.size()) {
    throw std::runtime_error("BIO_write: " + getErrors());
  }

  ssl::EvpPkeyUniquePtr key(
      PEM_read_bio_PrivateKey(bio.get(), nullptr, nullptr, nullptr));
  if (key == nullptr) {
    throw std::runtime_error("PEM_read_bio_PrivateKey: " + getErrors());
  }

  if (SSL_CTX_use_PrivateKey(ctx_, key.get()) == 0) {
    throw std::runtime_error("SSL_CTX_use_PrivateKey: " + getErrors());
  }
}
예제 #3
0
bool CSPMSession::loadFile(const QString & fileName)
{
  void * file;
  if (cspm_session_load_file(_hsSession, (void *) fileName.toStdWString().c_str(), &file))
  {
    if (_file != NULL)
    {
      cspm_file_free(_file);
    }
    _file = file;
    _fileName = fileName;
    _procCallNames = QStringList();
    _procCallNamesLoaded = false;
    _procs->clear();
    _events->clear();

    QString disp = QFileInfo(_fileName).baseName().replace(QRegExp("[^0-9a-z]"), "");
    _displayName = disp;
    int i = 0;
    QMap<QString, CSPMSession *> sessions = ProgramState::get()->getSessions();
    while (sessions.contains(_displayName))
    {
      _displayName = disp + QString::number(i++);
    }
    getWarnings();
    return true;
  }
  else
  {
    getWarnings();
    getErrors();
    return false;
  }
}
예제 #4
0
파일: SSLContext.cpp 프로젝트: axiak/folly
SSL* SSLContext::createSSL() const {
  SSL* ssl = SSL_new(ctx_);
  if (ssl == nullptr) {
    throw std::runtime_error("SSL_new: " + getErrors());
  }
  return ssl;
}
예제 #5
0
파일: SSLContext.cpp 프로젝트: 1Hgm/folly
void SSLContext::loadTrustedCertificates(const char* path) {
  if (path == nullptr) {
    throw std::invalid_argument("loadTrustedCertificates: <path> is nullptr");
  }
  if (SSL_CTX_load_verify_locations(ctx_, path, nullptr) == 0) {
    throw std::runtime_error("SSL_CTX_load_verify_locations: " + getErrors());
  }
}
예제 #6
0
파일: SSLContext.cpp 프로젝트: 1Hgm/folly
void SSLContext::setX509VerifyParam(
    const ssl::X509VerifyParam& x509VerifyParam) {
  if (!x509VerifyParam) {
    return;
  }
  if (SSL_CTX_set1_param(ctx_, x509VerifyParam.get()) != 1) {
    throw std::runtime_error("SSL_CTX_set1_param " + getErrors());
  }
}
예제 #7
0
void CSVWorld::GenericCreator::update()
{
    mErrors = getErrors();

    mCreate->setToolTip (QString::fromUtf8 (mErrors.c_str()));
    mId->setToolTip (QString::fromUtf8 (mErrors.c_str()));

    mCreate->setEnabled (mErrors.empty() && !mLocked);
}
예제 #8
0
파일: SSLContext.cpp 프로젝트: axiak/folly
void SSLContext::setCiphersOrThrow(const std::string& ciphers) {
  int rc = SSL_CTX_set_cipher_list(ctx_, ciphers.c_str());
  if (ERR_peek_error() != 0) {
    throw std::runtime_error("SSL_CTX_set_cipher_list: " + getErrors());
  }
  if (rc == 0) {
    throw std::runtime_error("None of specified ciphers are supported");
  }
}
예제 #9
0
void StatusHolder::raise()
{
	if (getError())
	{
		Arg::StatusVector tmp(getErrors());
		tmp << Arg::StatusVector(getWarnings());
		m_raised = true;
		tmp.raise();
	}
}
예제 #10
0
ISC_STATUS StatusHolder::save(IStatus* status)
{
	fb_assert(isSuccess() || m_raised);
	if (m_raised)
	{
		clear();
	}

	setErrors(status->getErrors());
	setWarnings(status->getWarnings());
	return getErrors()[1];
}
예제 #11
0
파일: SSLContext.cpp 프로젝트: axiak/folly
void SSLContext::loadPrivateKey(const char* path, const char* format) {
  if (path == nullptr || format == nullptr) {
    throw std::invalid_argument(
         "loadPrivateKey: either <path> or <format> is nullptr");
  }
  if (strcmp(format, "PEM") == 0) {
    if (SSL_CTX_use_PrivateKey_file(ctx_, path, SSL_FILETYPE_PEM) == 0) {
      throw std::runtime_error("SSL_CTX_use_PrivateKey_file: " + getErrors());
    }
  } else {
    throw std::runtime_error("Unsupported private key format: " + std::string(format));
  }
}
예제 #12
0
파일: SSLContext.cpp 프로젝트: 1Hgm/folly
void SSLContext::setSignatureAlgorithms(
    const std::vector<std::string>& sigalgs) {
  if (sigalgs.size() == 0) {
    return;
  }
#if OPENSSL_VERSION_NUMBER >= 0x1000200fL
  std::string opensslSigAlgsList;
  join(":", sigalgs, opensslSigAlgsList);
  int rc = SSL_CTX_set1_sigalgs_list(ctx_, opensslSigAlgsList.c_str());
  if (rc == 0) {
    throw std::runtime_error("SSL_CTX_set1_sigalgs_list " + getErrors());
  }
#endif
}
예제 #13
0
파일: SSLContext.cpp 프로젝트: 1Hgm/folly
void SSLContext::setClientECCurvesList(
    const std::vector<std::string>& ecCurves) {
  if (ecCurves.size() == 0) {
    return;
  }
#if OPENSSL_VERSION_NUMBER >= 0x1000200fL
  std::string ecCurvesList;
  join(":", ecCurves, ecCurvesList);
  int rc = SSL_CTX_set1_curves_list(ctx_, ecCurvesList.c_str());
  if (rc == 0) {
    throw std::runtime_error("SSL_CTX_set1_curves_list " + getErrors());
  }
#endif
}
예제 #14
0
파일: main_vs.c 프로젝트: Endruu/szakdoga
void main( int argc, char *argv[] )
{

	calibrateClock();
	filterBank[actualFilter] = defaultIirFilterInfo();

	for( i=1; i<argc; i++ ) {
		parseInput(argv[i], INPUT_BUF_SIZE);
		if( getErrors() ) {
			printErrors();
			clearErrors();
		}
	}

	while(1) {
		scanf("%s", inputBuffer);
		parseInput(inputBuffer, INPUT_BUF_SIZE);
		if( getErrors() ) {
			printErrors();
			clearErrors();
		}
	}

}
예제 #15
0
파일: SSLContext.cpp 프로젝트: axiak/folly
void SSLContext::loadCertificate(const char* path, const char* format) {
  if (path == nullptr || format == nullptr) {
    throw std::invalid_argument(
         "loadCertificateChain: either <path> or <format> is nullptr");
  }
  if (strcmp(format, "PEM") == 0) {
    if (SSL_CTX_use_certificate_chain_file(ctx_, path) == 0) {
      int errnoCopy = errno;
      std::string reason("SSL_CTX_use_certificate_chain_file: ");
      reason.append(path);
      reason.append(": ");
      reason.append(getErrors(errnoCopy));
      throw std::runtime_error(reason);
    }
  } else {
    throw std::runtime_error("Unsupported certificate format: " + std::string(format));
  }
}
예제 #16
0
파일: main_dsp.c 프로젝트: Endruu/szakdoga
void main(void)
{
	calibrateClock();
	initializeDevice();

	while(1) {
		if( pendingCommand ) {
		
			if( pendingCommand == LONG_COMMAND ) {
				// error
			} else {
				parseInput(inputBuffer, INPUT_BUF_SIZE);
			}
			
			if( getErrors() ) {
				printErrors();
				clearErrors();
			}
			
		}
	}
}
예제 #17
0
파일: SSLContext.cpp 프로젝트: axiak/folly
// SSLContext implementation
SSLContext::SSLContext(SSLVersion version) {
  {
    std::lock_guard<std::mutex> g(mutex_);
#ifndef SSLCONTEXT_NO_REFCOUNT
    count_++;
#endif
    initializeOpenSSLLocked();
  }

  ctx_ = SSL_CTX_new(SSLv23_method());
  if (ctx_ == nullptr) {
    throw std::runtime_error("SSL_CTX_new: " + getErrors());
  }

  int opt = 0;
  switch (version) {
    case TLSv1:
      opt = SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3;
      break;
    case SSLv3:
      opt = SSL_OP_NO_SSLv2;
      break;
    default:
      // do nothing
      break;
  }
  int newOpt = SSL_CTX_set_options(ctx_, opt);
  DCHECK((newOpt & opt) == opt);

  SSL_CTX_set_mode(ctx_, SSL_MODE_AUTO_RETRY);

  checkPeerName_ = false;

#if OPENSSL_VERSION_NUMBER >= 0x1000105fL && !defined(OPENSSL_NO_TLSEXT)
  SSL_CTX_set_tlsext_servername_callback(ctx_, baseServerNameOpenSSLCallback);
  SSL_CTX_set_tlsext_servername_arg(ctx_, this);
#endif
}
예제 #18
0
bool CSPMSession::reload()
{
  if (_file != NULL)
  {
    void * sess = cspm_session_create();
    void * file;
    if (cspm_session_load_file(sess, (void *) _fileName.toStdWString().c_str(), &file))
    {
      cspm_file_free(_file);
      cspm_session_free(_hsSession);
      _file = file;
      _hsSession = sess;
      _procCallNames = QStringList();
      _procCallNamesLoaded = false;
      _procs->clear();
      _events->clear();
      getWarnings();
      return true;
    }
    else
    {
      // To avoid repeating code, briefly change _hsSession.
      void * temp = _hsSession;
      _hsSession = sess;
      getWarnings();
      getErrors();
      _hsSession = temp;
      cspm_session_free(sess);
      return false;
    }
  }

  // No file, so this is a blank session - we don't add anything so there's nothing
  // to change, nothing to do.
  return true;
}
예제 #19
0
파일: SSLContext.cpp 프로젝트: 1Hgm/folly
void SSLContext::setCiphersOrThrow(const std::string& ciphers) {
  int rc = SSL_CTX_set_cipher_list(ctx_, ciphers.c_str());
  if (rc == 0) {
    throw std::runtime_error("SSL_CTX_set_cipher_list: " + getErrors());
  }
}