我用certutil创建一个数据库

myproject/bin/pkcert
echo "dartdart" > pwdfile
certutil -N -d 'sql:./' -f pwdfile

然后,我导入由授权机构验证的证书
certutil -d "sql:./" -A -t "C,C,C" -n "my_cert" -i certificate.crt

我检查是否有效
certutil -L -d 'sql:./'
Certificate Nickname                                         Trust Attributes
                                                             SSL,S/MIME,JAR/XPI

my_cert                                                      C,C,C

我的main.dart

library main;

import "dart:io";

void main() {
  var testPkcertDatabase = Platform.script.resolve('./pkcert')
                                   .toFilePath();
  SecureSocket.initialize(database: testPkcertDatabase,
                          password: 'dartdart');

  HttpServer
      .bindSecure(InternetAddress.ANY_IP_V6,
                  8443,
                  certificateName: 'my_cert')
      .then((server) {
        server.listen((HttpRequest request) {
          request.response.write('Hello, world!');
          request.response.close();
        });
      });
}

我执行,并得到此错误:
Uncaught Error: CertificateException: Cannot find server certificate by nickname: my_cert (OS Error: security library: read-only database., errno = -8126)

我错过了一些东西或应该报告错误?

谢谢。

最佳答案

您是否尝试将-s "cn=mycert"添加到

certutil -d "sql:./" -A -t "C,C,C" -n "my_cert" -i certificate.crt

并与

HttpServer
  .bindSecure(InternetAddress.ANY_IP_V6,
              8443,
              certificateName: 'CN=my_cert')

如本博客文章http://jamesslocum.com/post/70003236123所示?

关于ssl - Dart ,使用授权机构发出的SSL,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25873528/

10-12 01:10