久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

      <bdo id='5DffT'></bdo><ul id='5DffT'></ul>
    <legend id='5DffT'><style id='5DffT'><dir id='5DffT'><q id='5DffT'></q></dir></style></legend>

    <tfoot id='5DffT'></tfoot>

  1. <i id='5DffT'><tr id='5DffT'><dt id='5DffT'><q id='5DffT'><span id='5DffT'><b id='5DffT'><form id='5DffT'><ins id='5DffT'></ins><ul id='5DffT'></ul><sub id='5DffT'></sub></form><legend id='5DffT'></legend><bdo id='5DffT'><pre id='5DffT'><center id='5DffT'></center></pre></bdo></b><th id='5DffT'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='5DffT'><tfoot id='5DffT'></tfoot><dl id='5DffT'><fieldset id='5DffT'></fieldset></dl></div>

    1. <small id='5DffT'></small><noframes id='5DffT'>

      如何使用 mysqli 與 SSL 連接

      How to use mysqli connection with SSL(如何使用 mysqli 與 SSL 連接)

        <legend id='RKPLQ'><style id='RKPLQ'><dir id='RKPLQ'><q id='RKPLQ'></q></dir></style></legend>
        • <bdo id='RKPLQ'></bdo><ul id='RKPLQ'></ul>
              <tbody id='RKPLQ'></tbody>

            1. <tfoot id='RKPLQ'></tfoot>

              <small id='RKPLQ'></small><noframes id='RKPLQ'>

              <i id='RKPLQ'><tr id='RKPLQ'><dt id='RKPLQ'><q id='RKPLQ'><span id='RKPLQ'><b id='RKPLQ'><form id='RKPLQ'><ins id='RKPLQ'></ins><ul id='RKPLQ'></ul><sub id='RKPLQ'></sub></form><legend id='RKPLQ'></legend><bdo id='RKPLQ'><pre id='RKPLQ'><center id='RKPLQ'></center></pre></bdo></b><th id='RKPLQ'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='RKPLQ'><tfoot id='RKPLQ'></tfoot><dl id='RKPLQ'><fieldset id='RKPLQ'></fieldset></dl></div>

                本文介紹了如何使用 mysqli 與 SSL 連接的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                問題描述

                我正在嘗試與我的數(shù)據(jù)庫(kù)建立安全連接

                I'm trying to make a secure connection with my database

                我寫了以下代碼:

                <?php
                
                // form filled?
                if (isset($_POST['submit'])) {
                    $user = 'gebruiker';
                    $pass = 'gebruiker';
                    $db = new mysqli('localhost', $user, $pass, 'forum');
                    if (mysqli_connect_errno()) {
                        echo 'database doesnt work';
                        file_put_contents('MySQLiErrors.txt', date('[Y-m-d H:i:s]') .          mysqli_connect_error() . "
                ", FILE_APPEND);
                        exit();
                    } else {
                        $username = $_POST['username'];
                        $userspassword = $_POST['password'];
                        $salt = strrev($userspassword . substr(0, 4));
                        $password = hash('sha512', $userspassword . $salt);
                        $statement = $db->prepare("SELECT id,username FROM user WHERE username = ? AND password = ?");
                        $statement->bind_param("ss", $username, $password);
                        $statement->execute();
                        $result = $statement->get_result();
                        $statement->close();
                        $count = $result->num_rows;
                        if ($count > 0) {
                            session_start();
                            $_SESSION["username"] = $username;
                            header("Location: forum.php");
                        } else {
                            $_SESSION['Error'] = "Invalid username or password";
                        }
                    }
                    $db->close();
                }
                

                我還在 php.net 上閱讀了一些關(guān)于 SSL 連接的內(nèi)容,但我不知道如何在這種情況下實(shí)現(xiàn)這一點(diǎn).

                I also read something about SSL connections on php.net but I don't have any idea how to implement this in this case.

                http://php.net/manual/en/mysqli.ssl-set.php

                我的代碼在 fedora 21 上運(yùn)行并且運(yùn)行良好,但接下來我想要的是使用 SSL 的安全連接.

                My code is running on fedora 21 and it works fine but the next thing I want is a secure connection using SSL.

                推薦答案

                您不需要客戶端證書和私鑰,并且在大多數(shù)情況下,您不希望 MySQL 服務(wù)器驗(yàn)證客戶端證書.

                You do NOT need the client certificate and private key and in most cases you do NOT want MySQL server to verify the client certificate.

                但是客戶端必須使用 CA 證書驗(yàn)證服務(wù)器證書以防止 MITM.

                Client however MUST verify server certificate using CA certificate to prevent MITM.

                <?php
                $mysqli = mysqli_init();
                $mysqli->options(MYSQLI_OPT_SSL_VERIFY_SERVER_CERT, true);
                $mysqli->ssl_set(NULL, NULL, "/etc/ssl/certs/ca-bundle.crt", NULL, NULL);
                $mysqli->real_connect('hostname', 'user', 'password', 'database');
                $mysqli->close();
                ?>
                

                這篇關(guān)于如何使用 mysqli 與 SSL 連接的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

                相關(guān)文檔推薦

                store_result() and get_result() in mysql returns false(mysql 中的 store_result() 和 get_result() 返回 false)
                Call to undefined function mysqli_result::num_rows()(調(diào)用未定義的函數(shù) mysqli_result::num_rows())
                PHP Prepared Statement Problems(PHP 準(zhǔn)備好的語(yǔ)句問題)
                mysqli_fetch_array returning only one result(mysqli_fetch_array 只返回一個(gè)結(jié)果)
                PHP MySQLi Multiple Inserts(PHP MySQLi 多次插入)
                How do I make sure that values from MySQL keep their type in PHP?(如何確保 MySQL 中的值在 PHP 中保持其類型?)
                  <tbody id='2xf4Q'></tbody>

                    <bdo id='2xf4Q'></bdo><ul id='2xf4Q'></ul>

                      <legend id='2xf4Q'><style id='2xf4Q'><dir id='2xf4Q'><q id='2xf4Q'></q></dir></style></legend>
                        • <i id='2xf4Q'><tr id='2xf4Q'><dt id='2xf4Q'><q id='2xf4Q'><span id='2xf4Q'><b id='2xf4Q'><form id='2xf4Q'><ins id='2xf4Q'></ins><ul id='2xf4Q'></ul><sub id='2xf4Q'></sub></form><legend id='2xf4Q'></legend><bdo id='2xf4Q'><pre id='2xf4Q'><center id='2xf4Q'></center></pre></bdo></b><th id='2xf4Q'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='2xf4Q'><tfoot id='2xf4Q'></tfoot><dl id='2xf4Q'><fieldset id='2xf4Q'></fieldset></dl></div>

                          <small id='2xf4Q'></small><noframes id='2xf4Q'>

                          <tfoot id='2xf4Q'></tfoot>
                          主站蜘蛛池模板: 成人在线视频观看 | 日韩最新网址 | 久草热在线 | 中文字幕1区2区3区 日韩在线视频免费观看 | 久久夜视频 | 亚洲国产精品第一区二区 | 黄色免费网站在线看 | 成人av观看 | 久久精品在线 | 一区二区三区国产 | 天天操夜夜操免费视频 | 中文字幕在线观看av | 成人av播放| 免费成人av | 亚洲中午字幕 | 日日日操 | 国产精品高清一区二区 | 中文字幕在线一区二区三区 | 这里只有精品999 | 亚洲一二三视频 | 免费一区在线观看 | 天天草草草 | 在线不卡 | 国产欧美日韩一区二区三区 | 欧美日韩综合一区 | 密桃av | 久久爱综合 | 91精品在线播放 | 操久久| 免费的色网站 | 中文字幕免费中文 | 毛片免费在线 | 精品视频一区二区在线观看 | 欧美精品在线播放 | 999久久久久久久久6666 | 欧美国产视频一区二区 | 色综合久| 波多野结衣av中文字幕 | 麻豆视频在线免费看 | 久久久青草婷婷精品综合日韩 | 成人综合视频在线 |