I try to send apdu command via smartcard with Cryptotokenkit on IOS application but got some error
in debug log
[smartcard] slot refused to allocate exclusive session for the card
"error domain=cryptotokenkit code=-2 "(null)""
for my code please see below code
// connect to the card
mngr?.getSlot(withName: slotName, reply: {
(slot:TKSmartCardSlot?) in
let card = slot?.makeSmartCard()
if card != nil {
// begin session
card?.beginSession{
( success:Bool,error:Error?) in
if success {
// Send 1st APDU
card?.send(ins: 0x84, p1: 0x00, p2: 0x00,le:8){
(data:Data?,sw:UInt16,error:Error?) in
if error != nil {
print("sendIns error:",error!)
}else{
print("Response:",data!,String(sw,radix: 16))
//String(format: "%02X", data! as CVarArg)
}
}
}else{
print("Session error:",error!)
}
}
}else{
print("No card found")
}
})
So i'm not sure what i do wrong on this
Post
Replies
Boosts
Views
Activity
Hi Guys I try to use smart card reader with my ipad project and after trying to make init session with the card got error from cryptotokenkit
Message from debug log :
[smartcard] slot refused to allocate exclusive session for the card
"Session error: Error Domain=CryptoTokenKit Code=-2 "(null)""
// connect to the card
mngr?.getSlot(withName: slotName, reply: {
(slot:TKSmartCardSlot?) in
let card = slot?.makeSmartCard()
if card != nil {
// begin session
card?.beginSession{
( success:Bool,error:Error?) in
if success {
// Send 1st APDU
card?.send(ins: 0x84, p1: 0x00, p2: 0x00,le:8){
(data:Data?,sw:UInt16,error:Error?) in
if error != nil {
print("sendIns error:",error!)
}else{
print("Response:",data!,String(sw,radix: 16))
//String(format: "%02X", data! as CVarArg)
}
}
}else{
print("Session error:",error!)
}
}
}else{
print("No card found")
}
})