TDE core libraries
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ksslpemcallback.cc 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* This file is part of the KDE project
  2. *
  3. * Copyright (C) 2001 George Staikos <staikos@kde.org>
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Library General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2 of the License, or (at your option) any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Library General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Library General Public License
  16. * along with this library; see the file COPYING.LIB. If not, write to
  17. * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  18. * Boston, MA 02110-1301, USA.
  19. */
  20. #ifdef HAVE_CONFIG_H
  21. #include <config.h>
  22. #endif
  23. #include <kpassdlg.h>
  24. #include <tdelocale.h>
  25. #include "ksslpemcallback.h"
  26. int KSSLPemCallback(char *buf, int size, int rwflag, void *userdata) {
  27. #ifdef KSSL_HAVE_SSL
  28. TQString pass2;
  29. Q_UNUSED(userdata);
  30. Q_UNUSED(rwflag);
  31. if (!buf) return -1;
  32. int rc = KPasswordDialog::getPassword(pass2, i18n("Certificate password"));
  33. if (rc != KPasswordDialog::Accepted) return -1;
  34. TQCString pass = pass2.utf8(); // utf8 length may differ from TQString length
  35. const uint passlen = pass.length();
  36. if (passlen > (unsigned int)size-1)
  37. pass.truncate((unsigned int)size-1);
  38. tqstrncpy(buf, pass, size-1);
  39. buf[size-1] = 0;
  40. pass.fill(' ');
  41. pass2.fill(' ');
  42. return (int)passlen;
  43. #else
  44. Q_UNUSED(buf);
  45. Q_UNUSED(size);
  46. Q_UNUSED(rwflag);
  47. Q_UNUSED(userdata);
  48. return -1;
  49. #endif
  50. }