我正在尝试使用pyopenssl生成ac自签名X509v3 CA证书.我想要添加扩展权限密钥标识符(AKID)与包含主题密钥标识符(SKID)的keyid.
但我的以下代码块不会将SKID复制到AKID而是抛出异常.
代码如下
import OpenSSL
key = OpenSSL.crypto.PKey()
key.generate_key(OpenSSL.crypto.TYPE_RSA, 2048)
ca = OpenSSL.crypto.X509()
ca.set_version(2)
ca.set_serial_number(1)
ca.get_subject().CN = "ca.example.com"
ca.gmtime_adj_notBefore(0)
ca.gmtime_adj_notAfter(24 * 60 * 60)
ca.set_issuer(ca.get_subject())
ca.set_pubkey(key)
ca.add_extensions([
OpenSSL.crypto.X509Extension("basicConstraints", True,
"CA:TRUE, pathlen:0"),
OpenSSL.crypto.X509Extension("keyUsage", True,
"keyCertSign, cRLSign"),
OpenSSL.crypto.X509Extension("subjectKeyIdentifier", False, "hash",
subject=ca),
OpenSSL.crypto.X509Extension("authorityKeyIdentifier", False, "keyid:always",issuer=ca)
])
ca.sign(key, "sha1")
open("MyCertificate.crt.bin", "wb").write(
OpenSSL.crypto.dump_certificate(OpenSSL.crypto.FILETYPE_ASN1, ca))
Run Code Online (Sandbox Code Playgroud)
抛出的异常如下
Traceback (most recent call last):
File "C:\Documents and Settings\Administrator\Desktop\Certificate\certi.py", line 21, in <module>
OpenSSL.crypto.X509Extension("authorityKeyIdentifier", False, "keyid:always",issuer=ca)
Error: [('X509 V3 routines', 'V2I_AUTHORITY_KEYID', 'unable to get issuer keyid'), ('X509 V3 routines', …Run Code Online (Sandbox Code Playgroud) 我正在编写一个Android USB主机应用程序,我试图枚举与平板电脑连接的设备.我按照开发人员站点中的android USB主机文档中的代码进行操作.
我的代码如下
AndroidUSBActivity
public class AndroidUSBActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
USBClass usb = new USBClass();
ArrayList<String> deviceList = usb.GetUSBDevices(getBaseContext());
final CharSequence[] items = deviceList.toArray(new CharSequence[deviceList.size()]);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Select a Reader");
builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
String selectedDevice = (String) items[item];
dialog.dismiss();
TextView DeivceName = (TextView)findViewById(R.id.textView1);
DeivceName.setText(selectedDevice);
}
});
AlertDialog alert = builder.create(); …Run Code Online (Sandbox Code Playgroud) permissions usb android broadcastreceiver android-pendingintent
我有一个javacard,它安装了2个小程序.现在我想从两者中选择一个.目前我的工作方式是,我提供applet的cap文件,我从中得到它的AID.但我发现这种方法并不令人满意.所以
android ×1
java ×1
javacard ×1
openssl ×1
permissions ×1
pyopenssl ×1
python-2.7 ×1
self-signed ×1
usb ×1